Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
willol14037yYeah, I don't understand why Python doesn't have optional static typing :/ that would make the language so much more usable for real projects
@kpenc @ElectricCoffee but the type annotations are nowhere near as powerful as your average statically typed language. Simply because the class definitions in Python are not rigid enough :(
I am taking my personal projects more and more away from Python to Kotlin, since kotlin has even stronger checking than Java and the much desired type inference :)
This is not really a problem if you do proper testing, which you should do regardless of language anyway.
You can do static analysis in python with something like PyLint, it will find many errors.
@gggggggggg i hear this argument often, but it is nut entirely true. With a language like Java, you have completely removed an entire type of errors: type errors. That is a lot of tests you don't need to write.
In other languages, the compiler protects from null errors. More tests that need not be written.
So while we must always test, there are a lot fewer types of tests that need to be written for statically types languages. That is my point. And it is something that Python does not have. Even with linters
@gggggggggg it is totally a problem. Like @eldamir said you can remove a huge class of stupid tests. You just have to use a statically typed language to see the benefit. When the compiler guarantees your types match you have a very safe program. It won't throw shit errors in production suddenly like "NoneType is not iterable"! (To the Python interpreter: We all know that you giant fact machine! But that doesn't help right? Why the fuck did you accept that type in function then if it was of NoneType?)
I've been programming 5 years in Python and few months in Haskell. So my point view is based on my experiences. And the above error is one that I faced in prod recently.
@eldamir check out this project called mypy. It offers optional static typing for Python.
@rayanon I write statically typed code every day ;)
"NoneType is not iterable" is not an error that would be fixed by static typing, as that would cause e.g. a NullPointerException in Java.
You don't need special tests in dynamically typed languages.
Yes static typing prevents certain errors at compile time, but duck typing allows you to speed up your development time drastically.
As I said I use both and I don't clearly prefer either one, I'm just against the rampant fanboy/girlism on both sides.
That said, modern type systems like Rust's "trait" system aim to merge benefits of both static and dynamic typing and I'm excited to see where that will bring us.
@gggggggggg I would not consider Java to be an example of good typed language. Languages with powerful type systems have existed since the 70s (read ML family). They were considered highly academic and arcane until recently, and people are beginning to see the benefits of a good type system in terms of guarantees and safety it gives you. Just look at Facebook and Microsoft.
These type systems are quite different from that of Java/C#/C/C++. You should have a look.