6 ms·
I don’t think the only alternative to Haskell types is manually checking your program for consistency. For one thing, Clojure has type analysis: spec. Also, as
by jaredklewis 7y ago
I don’t think the only alternative to Haskell types is manually checking your program for consistency.
For one thing, Clojure has type analysis: spec. Also, as pointed out in the article, you can also write tests.
- yakshaving_jgt 7y agoHaskellers can and do write tests. +----------+-------+-------+ | Language | Tests | Types | +----------+-------+-------+ | Haskell | Yes | Yes | | Clojure | Yes | No | +----------+-------+-------+
- jaredklewis 7y agoAs I said above, clojure also has a type system. So your chart is yes for both features for both languages.
- yakshaving_jgt 7y agoI had taken it for granted that when someone says a language "has types", they mean it is statically typed as opposed to dynamically typed. This is also made obvious by the idiomatic use of each technology. So, no. My little chart is correct.
- badsavage 7y agoClojure has something like an extendable type system called Spec. We can create our own types lol
- badsavage 7y agoA great example here: https://news.ycombinator.com/item?id=18776215 https://news.ycombinator.com/item?id=18776215
- yakshaving_jgt 7y agoI am quite familiar with Spec. In my few years of professional Clojure experience, working with people who write Clojure every day, and enjoy it, and advocate using things like Spec, I have never actually seen anyone do it successfully in practice. I understand the idealist world view is seductive — we'll be discipined, we'll write the tests, we'll make good use of Spec, etc etc. In reality, I have never seen this happen. Humans are lazy and undisciplined, so that's what I optimise for.
- stingraycharles 7y agoWe use spec a lot, using orchestra’s defn-spec combined with expound for improved error reporting. It’s not a type system, but it’s very concise and easy to add validations to important functions. This removes the “lazy and undisciplined” part of the equation.
- badsavage 7y agoBasically you says if a type system is optional, people tend not to use it, because most of the times they are good without it. I agree. But we do use spec very successfully for complex data structure validations and example data generation.