To me, a non-Python user, this whole type checking this is hilarious and farcical. Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths. To now start static type checking - why even bother; you may as well use a real language with first class static typing support. Bolting it on as an after thought still makes me laugh hehe.
I haven't used Python's typing (mypy?), but... options are good, no? Like, you don't have to use mypy if you don't want to. But Python has a lot of strengths, and if someone wants to use those strengths but also get types, what's wrong with that?
While I haven't used mypy, I've used TypeScript a ton, and if mypy is half as good as TypeScript, I'm glad it exists.
Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths.
Dynamic typing is the easiest type system to implement in languages, and that's why scripting languages tend to prefer it. It has very significant costs, and the supposed benefits to the programmer are dubious at best. Static typing is technically better for a large number of reasons, but lately programmers have adopted the idea that "easy" is favorable over "good".
Dynamic vs. Static is not a question of what is better, it's a question of what problem you are trying to solve.
Do you need a lot of small highly flexible purpose-built scripts in an environment where the same data is likely to be passed around many formats (e.g. The Web)? Dynamic good. Static bad.
Do you need large rigorous algorithms, high performance, do you expect to share your tools, do you need more control under the hood? Static good. Dynamic bad.
Making Python able to do both is great for Planet Python. It's also extremely difficult to implement. Dynamic typing systems aren't easier to implement than static ones, it's just that it's a very early design decision that impacts a lot of how the compilers are written. Trying to do both is what is truly challenging. While this is an impressive thing for any language, it also creates a bit of an identity crisis and potentially puts in danger of becoming bloated.
For me, personally, if I'm at a point in my Python project where I'm thinking that I need a strong static type-system, that's the point where I say to myself, "Python wasn't the right tool for this job." Of course I've also started projects with static typing and later regretted the loss in flexibility upon realizing that the project has no need for static typing.
I think that's unfair to say that people just use dynamic typing is just used because it's easy to implement. Dynamic languages are often easier to learn which is likely part of the reason why python is good for beginners. Also dynamic languages can make it quicker to write code since you don't have to write out type declarations. This is useful for small scripts where you don't really need many benefits from static typing.
Is something good for beginners because it is easy? I see this often asserted as something that is intuitively true, but I really don't think that it is. Good languages for beginners are the ones that are strict and explicitly tells you that you're doing something wrong, rather than silently trying to guess your intention and automatically try to fix subtle errors. This is not a favor to the student
As I noted directly to them, seems a rather strong pro-Python contingent on reddit who downvote anything negative about Python (or positive about languages deemed competitors) - whether or not it’s said reasonably.
I don't see the downside. You get flexibility when you need it and you get type checking when you need it. I use type checking on the 10-20% of the most relied on, complicated, or data-intensive code.
Then, since the IDE supports static analysis, it catches silly mistakes or errors before they even have a chance to become a bug which improves Dev efficiency a lot. It's also useful to make sure you use proper data structures (ex deque instead of list).
and it's lack of type checking (at least until run time) is one of it's strengths
And this is a "strength" how, exactly? You enjoy the guessing game instead of having precise autocompletion in your IDE? Have too much spare time to waste?
Bolting it on as an after thought still makes me laugh hehe.
What's wrong with improving an IDE support at least for a bunch of common libraries?
Apparently you're one of those who think that type systems are for "checking", "correctness" and all that crap. They're not. They're for this little autocompletion and "jump to definition" thingies on your IDE, primarily. The rest is of a much lesser importance - performance, "correctness", documentation, and so on.
So...C and other early languages being statically typed was all done in anticipation of the IDEs we would have 40 years later? That's completely backwards. IDEs make use of a feature which exists for performance and determinism, not the other way around.
What's wrong with improving an IDE support at least for a bunch of common libraries?
Agreed here, but I think the other guy was referring to bolting features on to Python itself. Which is kind of an odd complaint itself, since every language I can think of has had multiple releases with new features.
Unless you've been sarcastic this whole time and it's gone right over my head...
So...C and other early languages being statically typed was all done in anticipation of the IDEs we would have 40 years later?
Firstly, ctags and similar tools existed long before the modern IDEs. Secondly, back than priorities were different, typing existed for performance primarily.
IDEs make use of a feature which exists for performance and determinism, not the other way around.
And? Priorities are different now. Most people do not care too much about performance. Especially if we're talking about Python.
but I think the other guy was referring to bolting features on to Python itself
You cannot improve IDE support without fixing a language.
Everything Python is is "stuff bolted onto it after the fact"; in that sense it's quite the dynamic C++ and guess what C++ also now has support for dynamic typing.
And I'm not talking about "auto"; I'm talking about std::any where a datum is stored together with a type tag in a fat pointer that preserves the type information at runtime which can be queried.
Yeah it turns out you can simulate dynamic typing in static typing in terms of just making every expression the same type to some kind of struct which stores the type info in a field.
That's pretty much what all those implementations that compile a dynamic language to C do; they define something like a struct called SchemeObj and have a field for the type tag and pass that around everywhere.
Yeah, but it's not a language feature is my point. It's harder to use because of it.
Example. Ever used Objective-C? They have an NSValue type you can use to box anything, but without special language features to help, it's cumbersome to use. Here's what it's like. It's probably not as bad in C++ with operator overloading and stuff like that, but this sort of thing is what I'm skeptical about with regards to bolted on features.
-61
u/leftofzen Jun 28 '18
To me, a non-Python user, this whole type checking this is hilarious and farcical. Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths. To now start static type checking - why even bother; you may as well use a real language with first class static typing support. Bolting it on as an after thought still makes me laugh hehe.