4 ms·
Clojure is such a different school of thought! Most of the arguments I have heard for Clojure (immutability, thinking in data, etc) also apply to ML though. Sti
by de_keyboard 6y ago
Clojure is such a different school of thought! Most of the arguments I have heard for Clojure (immutability, thinking in data, etc) also apply to ML though. Still, I hope to try it out properly one day!
I wonder what is easier for a strong OOP developer to learn, Lisp or ML?
- pjmlp 6y agoLisp and Clojure have CLOS, which is more powerful than what most people know as OOP. ML, depending on the flavour gets pretty how one combines functors, aka generic modules, which is similar to component based programming like COM, or just plain objects as in OCaml. Now the immutability isn't as hard to adapt to as one may think.
- lispm 6y agoClojure has CLOS? That would be new.
- pjmlp 6y agoFair enough, I was over simplifying, still it has a nice subset of it.
- lispm 6y agoWhat is this 'subset'? CLOS is based around class&inhertance&mutability + generic function dispatch over classes. Spiritually Clojure wants to avoid OOP, where CLOS is a full object system with an optional meta-layer.
- pjmlp 6y agoI know you are a Lisp expert with a deep knowledge of its eco-system, but trying to downplay the existence of multiple dispatch and protocols doesn't help. Also I bet that The Art of Metaobject Protocol reference implementation can be ported into Clojure without major issues.
- lispm 6y agoThe Art of the Metaobject Protocol has no 'protocol reference implementation'. Neither CLOS nor AMOP supports explicit protocols. Explicit protocols are a feature of Clojure. https://clojuredocs.org/clojure.core/defprotocol https://clojuredocs.org/clojure.core/defprotocol "A protocol is a named set of named methods and their signatures" Such protocols are not a language feature of CLOS. AMOP describes a 'Metaobject Protocol' (MOP) and has a tiny example implementation (called Closette). This is entirely different from what the 'protocols' feature does in Clojure. A 'protocol' in AMOP is informal. What AMOP actually describes with its MOP, is a meta-level of meta-classes and generic functions, which implement large parts of CLOS itself. Such the classes, generic functions, methods, slot descriptors, etc. are CLOS objects themselves. Clojure supports a form of multiple dispatch, but the dispatch mechanism is also very different from CLOS - for example it uses a dispatch method per generic function, selects one method and has no idea of a next method. CLOS for example uses a built-in dispatch mechanism, multiple class-based dispatch hierarchies for multiple arguments, using a set of methods which are selected based on the class hierarchy. https://clojure.org/about/runtime_polymorphism https://clojure.org/about/runtime_polymorphism Typically it is not a good idea if Clojure uses a name for a feature, to generally think that this is similar to a feature with a similar name in Common Lisp -> 'protocols' and 'meta-object protocol' are two very different things. Porting the CLOS MOP to Clojure would be possible, when one first implements CLOS in Clojure. Otherwise it makes very little sense, since Clojure does not by default support the (older) view of object-oriented programming of CLOS. Something which the Clojure designer thought of a feature: getting rid of things like mutable objects, class based inheritance, class-based OO, etc.