3 ms·
IME dynamic typing is super easy and fast until it suddenly isn't. Then you're going through ten layers of functions to check if None is a valid value for some
by colatkinson 7y ago
IME dynamic typing is super easy and fast until it suddenly isn't. Then you're going through ten layers of functions to check if None is a valid value for some parameter because some intern three years ago figured that would be the easiest way to do it.
I'd say that while there's certainly a ton of purely dynamically-typed code out there, there's also a current reversal of the trend, with static and gradual typing coming back in vogue. Python has fully-supported type annotations, and Typescript is the trendy new way of writing JS. Facebook has ReasonML and Hack/PHP 7. Go and Rust, the current "cool kid" languages, are fully statically typed.
I think that the bad taste left in people's mouths by "enterprise" Java and its 30-character type names is fading, and that we'll see a few years of static types. Then of course the cycle will repeat itself, as is tradition.
- dkersten 7y agoMy favourite language is Clojure, but this exact thing leaves a bad taste sometimes. Clojure has the attitude that you should validate on the edges, using spec or similar, and then have dynamic types in between. This is really super convenient! However, as the codebase grows, subtle type errors do slip through and it gets rather hard to catch, since its now a runtime error that may not happen until a long time later (and then Clojure's notoriously bad error messages certainly don't help). So you hope your test suite catches it. Luckily, with generative property-based testing, which Clojure has reasonable support for, this can often get caught early, but during tests is still not as early as with a type checker and generative tests could still take a very long time to catch subtle issues (but it catches a lot more than just type errors!). Of course, Clojure also encourages developing in the REPL, so most of the time, you can be pretty confident that it will work before you even run the tests. Still, I feel like some kind of static typed Clojure (not a separate thing like Typed Clojure, which is slow and clunky, but something with first-class static type checking as part of the language) would be awesome. Maybe in reality it would conflict with many of Clojure's other niceties though.