3 ms·
There is part of me that wants to laugh at people independently discovering over and over again that static typing is actually useful after dismissing it, but I
by emodendroket 7y ago
There is part of me that wants to laugh at people independently discovering over and over again that static typing is actually useful after dismissing it, but I'm just glad it's available more places.
- fjp 7y agoI won't deny that static typing is great. You're just never going to get rid of Python. Python is just an incredible language to learn programming in and an extremely productive language for building small-to-medium sized apps. Type hints + making type checking part of the build stage helps, a lot in my opinion. With these + tests in place I almost always experience that I can refactor safely. I would use a statically typed implementation of Python in a heartbeat, I really hope it gets made.
- shpx 7y agoHave you heard of https://nim-lang.org https://nim-lang.org
- epage 7y agoI keep hearing about nim and I've normally ignored it because Rust is good enough for me. Recently, I got curious if itd be a good fit for my coworkers, so I started giving it a look. I'm baffled at all the python comparisons. Yes, it as significant white space, but that felt like it. It felt more like Ada or some other language than python. The one thing I did appreciate was `(;)` for turning statements into expressions. I've grown to love having complex expressions in Rust and miss them in other contexts. However, Python's scoping reduces the need for them.
- tomnipotent 7y agoDon't be silly, no one is claiming to be "independently discovering" anything. Typing is a tool, just like anything else. When I'm working with Python, I specifically want types during development (thanks PyCharm) but not at runtime. I spend a lot of time in my code, and type hints provide the same structure to Python code that they add to Java except when I don't want to worry about them.
- ptx 7y agoWhat are you referring to when you say you don't want types at runtime? Every Python object has a type and type-checks will be performed at runtime (e.g., "hello" + 42).
- tomnipotent 7y agoDuck typing. A Python object doesn't have to have a specific type, just the attribute(s) you want. You'll find a lot of "hasattr(obj, x)" throughout any large Python code base. It's nice to not have to worry about creating single-method/single-attribute interfaces and dot them all over the place.
- ptx 7y agoGood point. But how can you know the types statically (at development-time) without defining interfaces?
- emodendroket 7y agoYou could specify that your method takes an object which has method XYZ accepting an int as its parameter and returning another int -- a kind of "anonymous" interface, I guess. Personally I don't like this kind of stuff because there's no guarantee that two objects with a convert method do the same thing when that method is called.
- emodendroket 7y agoWhat I mean is, a while ago you were hearing a lot of ra-ra stuff about how great dynamic languages were because static typing was just a waste of time that made you less productive. And then sooner or later all those languages evolve a documentation system with types in it, and then type hints, and so on, as it becomes clear that those earlier claims weren't true for long-lived projects.
- dragonwriter 7y ago
- swiley 7y agoThe addition of type hints to python is a huge part of what pushed me over the edge. I kind of wish I had tried it earlier, it's pretty awesome for PoC and fairly simple programs.