2 ms·
My 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
by dkersten 7y ago
My 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.