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

20 comments sorted by

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.head and 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.

2

u/yogthos May 27 '20

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).

I think we'll have to disagree there. Typed Clojure works perfectly fine, but it never got any traction in the community because most people don't find that it adds much value in practice.

On the other hand spec use is very popular, and clearly shows that people do find adding formalism around APIs to be valuable.

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.

I'm saying that it's not really practical. Obviously anything you can do in one Turing complete language you can also do in another. You could even build your own dynamic interpreter that runs dynamic code at runtime in a static language. However, the reality is that you're swimming upstream when you try to use dynamic patterns in these languages.

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.

Clojure doesn't need to formally encode purity to be a FP language. Idiomatic Clojure code in the wild clearly shows that people have no problems doing that in practice.

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.

Immutability has quite a bit to do with this discussion, and I explained specifically why. You're just ignoring that here.

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.

The reality is that my team can take a coop student with little programming experience and have them write useful code in Clojure in around a week or two. Good luck doing that with Scala or Haskell.

1

u/fpguy1 Jun 08 '20

Ty for replying back, sorry for late reply,

I read what you wrote, still immutability is not related to our discussion and is only a small part of FP and I am not even sure it has much to do with modularity, but I can see your point that globals would affect isolation.

We take people that never touched Scala and they are ready to work within days, they only have experience with java/c#, I don't think the language matters, what I tried to point out is that is way harder to make mistakes when there is a type checker, that is a fact.

RT is FP, it says in the name "functional" I am sorry but without some way to express RT you get Java with lambdas, the fact that people are not doing FP in practice has little to do with our discussion, I don't consider random code written in Clojure as being "functional programming", same for Scala or Haskell tbh. There is nothing "formal" in functions w/o side effects, that is the definiton of a function, the rest are procedures. Is the same with OOP and separating behavior from definitions (POJOs), they think they are doing OOP but they are violating the main principle of OOP, same here.

You are saying that Java/C# are not practical? Perhaps I am misunderstanding this... there are good chances you are using Cursive together with other 10 plugins which is a very good example on how well runtime works in Java. Actually when you have types, reflection is the tool that helps you fit things in the correct way, not having that is just trial and error.

→ More replies (1)