3 ms·
Python type hints are a step backwards in the evolution of programming languages. There, I said it. Before the pitchforks come out, I love types and I love dyn
by nine_zeros 4y ago
Python type hints are a step backwards in the evolution of programming languages. There, I said it.
Before the pitchforks come out, I love types and I love dynamic languages too.
But if I have to create a struct[struct[struct] for a type, and then import it with an obnoxious "if TYPE_CHECKING:" and then have to use an IDE that can do static analysis to even make sense of types, I might as well use a well-designed JVM language.
- rowanG077 4y agoThis. I tried to love gradually typed languages. But they just seem as the worst of both worlds to me.
- saiojd 4y agoI kind of agree, but I feel like the retrofitting of gradual types onto existing languages is often awkward even though the idea of gradual typing itself is very good.
- captainmuon 4y agoI dont't know, I have the opposite experience. In Python you can have a function that returns a certain object `Publication` most of the time. But sometimes it returns a slightly different object `MyPublication`. This doesn't have to be due to bad design, maybe it comes from some library function and you didn't even notice. Due to duck typing it will work (until you do something with the result that only one version supports). Then sometimes you will return None, and sometimes "[something]". Type annotations are really valuable to ensure that your types are actually what you think they are. In the same spirit of using assertations for pre and post conditions.
- nine_zeros 4y agoWhat you are enjoying is called a good type system, not Python's type annotation specifically. The comparison is with other typed/type-hinted languages, not with Python 2.7.