3 ms·
I used to think that, too, but Clojure is not dynamically typed in the same way Ruby, Python, Javascript or Groovy are. The most important difference, from a ma
by pron 13y ago
I used to think that, too, but Clojure is not dynamically typed in the same way Ruby, Python, Javascript or Groovy are. The most important difference, from a maintainability point of view, is dynamic dispatch. All those other languages can call any method on any object. If the object has that method - it runs; if not - something else happens. But other than comparing method names, you have no way of knowing whether method foo in object A is indeed an override of method foo in object B, or whether it does something else altogether.
Clojure is entirely different. When you write (f x) you know exactly how f is going to dispatch by looking what f is in f's namespace: either it is a simple function, a protocol method implemented by x (just like interfaces in Java) with the protocol defined in f's namespace, or a multimethod in f's namespace.
So in Clojure, you don't have dynamic dispatch at all other than Java-like polymorphism or multimethods whose implementations are confined to a single namespace.