Hacker News new | ask | show | jobs
by dinduks 4701 days ago
Scala is statically typed while Clojure is dynamically typed. Comparing them is irrelevant.

> There's almost no excuse not to use Scala if you're deploying on the JVM.

s/deploying on the JVM/a Java developer/

1 comments

It's a bit of a simplification to say that Clojure is dynamically typed - for instance, all of the builtin data structures conform to particular interfaces (for instance Seq) and operations over those abstractions are resolved statically. You can even make it into a parens-y Java with raw method calls, and tell it to warn you if it can't resolve a call statically (albeit you usually have to hint the initial input).

There's also things like protocols, and Typed Clojure.

Protocol method references being resolved statically is just an optimization — it is not at all the same thing as a static type system like Scala has. There is no easy way in Clojure to say "This function takes an Address and a PhoneNumber" and have the compiler throw an error on compilation if Insufficiently Caffeinated You accidentally passes an integer in place of the PhoneNumber.

The typed module implements a static type annotation system and type checker on top of the dynamic language, which is nice, but that still doesn't mean Clojure is statically typed.