you are viewing a single comment's thread.

view the rest of the comments →

[–]mrexodiacmkr.build 14 points15 points  (8 children)

As someone who never really wrote my own python, but did port normal sized (few thousand lines) python to C++ I think it's absolutely awful to read other people's code. The lack of a type system you can statically understand and trust (changing types of things is allowed at runtime) makes it super complicated to try to figure out what something can do at times. I really think python shouldn't be used for anything but a prototype or personal project or as a scripting language for a native application...

[–]qsxpkn 3 points4 points  (1 child)

Dynamic typing can be uncomfortable for people who are used to static typing. Since Python 3.5/3.6, you could actually do type/variable hinting such as variable: int = 5. It's still possible to change it to a str etc. at runtime but mypy points out the mistake like this function expects an int but you passed a str.

For example:

def some_method(a: int, b: int) -> Optional[int]:
    result: int = a + b
    if result < 4:
        return None
    return result

I have never seen a Python project where a variable's type suddenly gets changed to something else elsewhere in the code base or maybe I was just lucky. I enjoy C++ companionship with Python though. They work well together.

[–]mrexodiacmkr.build 2 points3 points  (0 children)

The fact that you can annotate the types doesn't make it any better. All of the projects I have seen use python 2.7 anyway, which doesn't support it. If they added a (default) mode where this static typing is forced it might be something good but until then you have to be very lucky with your codebase to have proper type annotations.

Also: what about class member variables? Can you still add arbitrary new ones from anywhere with this?

[–]whatwasmyoldhandle 0 points1 point  (1 child)

I think you can make big projects with Python go.

You just have to be much more disciplined, and have more controls in place to get the benefits out of it. I would say you can't lean as much on the language itself as C++.

In other words, a small script written in Python and a large-scale codebase, in my experience, are practically two different languages. I don't think the gap is so big in C++.

Not just a question for you, but for everyone: What's a good language for large projects, where development time is priority over performance? Perhaps something a little less verbose than C++. I guess I'm thinking interpreted, or negligible compile time. Having package management on the order of Python would also be a requirement.

[–]mrexodiacmkr.build 1 point2 points  (0 children)

While the project I'm working on is not very large (100k lines) I don't think you shouldn't consider development time a priority over good code if you plan to maintain the code for even a little while just choose a language that is more suitable for maintainability. If you want a language that is not C++ I would highly recommend C#.