4 ms·
There are people in both Twitter and HN comments saying "if you want types, just use a typesafe language". What I found though, is that 'typed' Python is a gre
by hannofcart 6y ago
There are people in both Twitter and HN comments saying "if you want types, just use a typesafe language".
What I found though, is that 'typed' Python is a great language/dialect in its own right.
There's a confluence of simplicity and ergonomics that I find quite appealing, even as compared to mainstream static typed languages.
I had previously submitted to HN with my thoughts on this:
https://news.ycombinator.com/item?id=25520411 https://news.ycombinator.com/item?id=25520411
I think the primary difficulty I have seen people face is getting a buy-in from all members of the team. One or two members in every team seem to prefer to write Python the "way it was originally intended" and consider type annotations more of a nuisance. And this ends up hurting adoption.
- 127 6y agoI found myself writing this kind of code recently: https://pastebin.com/fpQzRypp https://pastebin.com/fpQzRypp Sometimes code is being plugged between two highly unstable things. It just needs to work and can't trust that any of the data it receives is valid or good. I should really be using types here.
- hannofcart 6y agoIndeed, you'll find that type annotations and enforcing them with a type checker will eliminate all those `assert`s for `not None`.
- zo1 6y agoIt won't eliminate it, but... At the very least it'll "push it back" quite close to the point in your code where someone made a not-so-well-thought out decision to accept nullability into a variable and let it propagate that uncertainty into the rest of the system.
- zo1 6y agoAs an anecdote: I've encountered, in production, a large order of magnitude more "null reference" errors in statically compiled languages than I have in python. But, people that propagate inconsistent state into their application exist on both sides, and having a statically-typed language doesn't necessarily shield you from the consequences.
- dehrmann 6y ago> 'typed' Python is a great language/dialect in its own right. Like OO in Python, it feels bolted on. The syntax for generics is bad, at least compared to Java. Typing also exposes how poorly thought out Python's collections are. The hierarchy and methods make sense, but some things are in typing, others in collections.abc. It also falls over when using things like functools.partial. Then there's the frequent complaint that if you're going to go to the effort to use something typed, you should use something that can take advantage of those types during compilation to optimize the code.
- zo1 6y agoI think the bolted-on feel is actually a "pro". It's a natural evolution, with the new features essentially being bootstrapped and in a lot of cases, exposed inside and using the language itself, rather than as some compiler afterthought.