3 ms·
Don'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 specif
by tomnipotent 7y ago
Don'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 agoYou see the same in reverse with many industrially popular statically typed languages gaining dynamic escape hatches, such that optional static typing, from one end or the other, is pretty much the uniform rule for industrially popular languages.
- emodendroket 7y agoThat is true, but as I see it the use of the dynamic features in statically typed languages tends to be much more limited, with most preferring it as an absolute last resort.
- joshuamorton 7y agoReally? I feel like stuff like DI frameworks are super common in Java, and they're essentially dynamic magic.
- emodendroket 7y agoI'm more familiar with C#, so there may be differences, but while the DI containers do do a lot of dynamic work, it is carefully abstracted so that all code the user writes to interact with the container is type-safe. It's very rare for methods in these languages to return object or dynamic, and slightly less rare but still far from common for these to be arguments. Isn't enabling this style exactly why generic support was such a big deal?
- 7y ago