r/Clojure • u/fadrian314159 • Jun 23 '26
FOL (Functional Object Lisp) 0.1.1 is released
/r/lisp/comments/1udsu25/fol_functional_object_lisp_011_is_released/
13
Upvotes
r/Clojure • u/fadrian314159 • Jun 23 '26
View all comments
Show parent comment
3
u/fadrian314159 Jun 24 '26
When I first conceived of FOL, it was planned as a simple Clojure system that used Common Lisp as a base. And, just as Clojure had protocols and multimethods that it shared with it's JVM substrate, I needed a way to integrate Common Lisp objects into FOL. Doing so by dumbing down the model seemed to be a non-starter to me. I'm my opinion, CLOS and the MOP was too powerful a tool to be left behind.
Hickey had four main objections to the use of CLOS-style objects. First, he objected to objects in the first place because they were containers for mutable state. I took care of this objection by using the MOP to make persistent objects (from which all objects are defined) immutable. You can assoc/dissoc their slots which produce a new version of the object, but you cannot mutate them in place. Second, he thought that objects coupled state and identity. By making objects immutable and returning new copies on mutation, one decouples an object's state from it's identity. Third, there was the "blob" problem. Hickey thought that data should be data, separated from encapsulation. I looked at a map and saw a smaller form of encapsulation. Whenever you treat a collection of data as a single thing, you are conceptually forming an encapsulation. In the final analysis, unless you want to handle your data as completely atomic data, you will have encapsulation. I simply didn't see the encapsulation in objects as any more or less detrimental than the encapsulation in maps. That might be my Smalltalk history talking, so take from that what you will. Finally, Hickey saw CLOS and its MOP as a complexity trap. To that objection, I do admit to a fair amount of sympathy. CLOS is a beast, especially when you add in the MOP. However, it is also a source of power. In addition, most objects designed via CLOS are fairly benign, with shallow inheritance chains and mixins that are little more than Java's protocols.
When designing FOL, I chose to include CLOS because it provided the user a powerful object system, should they need it, as well as Clojure's maps. I did not want a simplified single-inheritance object system that would not give the users the modeling capabilities they needed.
The next question, when you add two encapsulation mechanisms to a language, is how the user should choose between these two encapsulation methods. My answer is this: if one is using a collection of data which will be dynamically extended during program execution, use maps; if there is a good reason to use objects, like code sharing via inheritance, static structure sharing, etc., use objects.
Finally you describe FOL as a "mish-mash". Most languages are a mish-mash when you get right down to it. If Rich was a purist when he designed Clojure, he would not have included protocols and multimethods at all, opting instead for simple functions to do the heavy lifting. However, he saw the usefulness of having object-like structures in the language and added them. I had a similar decision to make. I chose a different path which integrates with my substrate language.
Anyhow, if nothing else, I hope this explains my reasoning. I spent a fair amount of "hammock time" on this decision. It's a tough one. In the end, and I think I made the right decision for FOL.
Of course, I'm always able to take in different points of view, so feel free to add your thoughts.