3 ms·
> run-time contracts and things like Clojure.spec come about to help fill the void of static typing If you look at clojure.spec as a replacement for a type sys
by hcarvalhoalves 9y ago
> run-time contracts and things like Clojure.spec come about to help fill the void of static typing
If you look at clojure.spec as a replacement for a type system, you'll be frustrated. The focus is on expressiveness, not proof. It's quite a different beast.
The leverage comes from the fact specs are data, and therefore usable at runtime, which usually isn't possible due to type-erasure.
Not having a chasm between compile-time and runtime allows extending the language. You can run clojure.spec checks, or a full type system (like Typed Clojure), etc. The entire mindset is based on "there's only runtime".
The discomfort comes from comparing that to a language that has a canonical type system, and evaluates type definitions in what is essentially a separate runtime only available in the compiler. Apples, oranges.