I believe that they represent quite a few new innovations within Clojure.
CLOS is a fairly complex, fully featured, object-oriented system. It presents the various OOP methods that you often hear about and that exist in other object-oriented languages ββ- multiple inheritance, dynamic dispatch, general functions, etc.
Clojure takes a different approach: types and records are much simpler than a full OOP and are not designed to create a complete OOP system. Rather, I understand that the design is motivated:
- The belief that many OOP methods are actually harmful when building large systems is implementation inheritance, for example
- The ability to get maximum performance (the same as Java) for the most common case of polymorphism (i.e., separate sending by type)
- Desire to solve a problem you can do in Clojure using deftype / defrecord along with protocols
- The goal is to make all records / types immutable to fit the rest of the Clojure philosophy
If you want a traditional object-oriented system such as CLOS, you could build it in Clojure on top of types and records. You can also use Java style object orientation directly within Clojure. However, I believe that this is usually not recommended by Clojure experts - Clojure usually offers you different or better solutions to the same problems.
In general, Clojure tends to provide you with βsimpleβ tools that you can put together to solve the problem, rather than defining a complex structure at any point. This is an interesting philosophy discussed in this video with Stuart Hallow.
source share