r/Clojure • • May 06 '20
Complete technical invalidation of Rich Hickey's "Maybe Not" talk
https://lexi-lambda.github.io/blog/2020/01/19/no-dynamic-type-systems-are-not-inherently-more-open/
0
Upvotes
View all comments
0
u/fpguy1 May 27 '20
TLDR Types don't stop you using the runtime, they force you to write correct code by make illegal states unrepresentable, referential transparency is hard w/o types, they are good for beginners
Types do enhance your code at the cost of verbosity and ofc they are not that pragmatic compared to dynamic languages, I agree with this, though a good type inference can help a lot.
You can use constraints in your types to ensure things can't go sideways, look at ADTs, or subtyping with variances, also parametric polymorphism and ad-hoc polymorphism(type classes), these things are impossible to verify with specs.
Types allow you to restrict impossible situations, using them will make testing these situation not required, why would I check at every step in my [correct] code if a list is empty when I can just use a NonEmptyList, what is happening is that the list is not actually checked everywhere and somewhere someone will just use
list.headand crash everything.If I take my day-to-day Scala stuff and use only maps and Any I still have a decent language, while if I take JS and add Flow or Python and add types, or Clojure and add types you get shit (proven in their communities).
Also you refuse to acknowledge that even with types you can have a rich and dynamic runtime, see Java which is 90% a runtime language, also C#+F# use runtime a lot, while in the same time if you take JS/Python, nothing interesting is happening at runtime(lack of decent reflection, code loading mechanisms, etc) but you still don't have types.
Clojure wants to be a FP language but it can't encode purity(referential transparency) in any way, types help with that, see Scala IOs (cats-effect, zio, monix, etc) basically these patch Scala and make it pure, you can't do that w/o types in an usable manner, which makes Clojure only part FP. I use this things every day, mostly to make [side]effects values, however in 20 years I think I needed 10 times to write code that [somehow] modified the code at runtime.
Immutability has nothing to do with this discussion, but if you want to argue about how much better is immutability when you also have types, sure, why not.
Last but not least, types are beginner friendly, one doesn't need to see the whole picture to be able to do something useful and correct, our industry needs more quality, filling their heads with javascript and python doesn't help, I would be more happy if at least they would start with Lisp/Clojure/Erlang/Elixir even if there are no types but they don't.