I've been exploring CLOS for the past couple of weeks.<p>From what I can tell, it seems especially nice for a system that needs extreme flexibility. I like to program MUDs and rougelikes as side projects, and after initial exploration, CLOS seems perfect for that - it can enable certain interactions that I would otherwise have to spend a lot of work and design achieving in other languages. It turns what feels like a chore in other languages into something fun.<p>I would imagine that how much this is a pro or con depends upon the work you do. Some might see such potential flexibility as error prone and overly complex because the domains they work in don't require such complexity. But others might see it as the building blocks for a domain with complex interactions that they have to build regardless of the language they use.
Alan Kay’s immortal quote about OOP:<p>> OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.<p>[<a href="http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en" rel="nofollow">http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay...</a>]<p>His reference to ‘LISP’ is, of course, referring to CLOS.
<p><pre><code> I don’t know the exact implementation details of CLOS, but I feel that it can be easily replicated in C by adding the needed metadata in the structure and doing the needed type checking in the functions.
</code></pre>
And thus Objective-C was reborn
isnt this just a small journal entry saying, "i started to learn clos and i think i like it". i dont see any siginificant information about why clos is great here. doing general oop in lisp is powerful from the get-go because you can update classes and instances interactively. you will use clos for this basic functionality. however clos also allows you to extend the oop ideas in directions that are just not available in other languages
Meh.. I code in Common Lisp at home and Java professionally and I've never understood why people praise the CLOS so much. Like the author says, 99% of the time you don't have a reason to use OOP, and the few times you do you'd prefer to use as little as possible to keep everything sane. It's also one of the few parts of CL which are not optimized well by default, using structs or other basic data structures instead of objects has visible performance benefits in SBCL if you care about that for some reason.<p>Yes I'm aware of the things you get in CL you don't get in Java: multiple inheritance, defmethod works on arbitrary types by default rather than having to create interfaces, better introspection.. but I don't care. If you're using these features so much there's probably something overly complex with your code to need to do so. Or you're working in such a complex domain you need to, in which case go ahead..
> I don’t know the exact implementation details of CLOS, but I feel that it can be easily replicated in C<p>This makes me think he's barely scratched the surface of what CLOS has to offer.
The definitive book on implementing CLOS (not how to use it) is <a href="https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol" rel="nofollow">https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Prot...</a>
If you like CLOS, be sure to look up "The Art of the Meta-Object Protocol." It Was written by people who were at PARC back in the day so were on the ground when Smalltalkish concepts were being developed and extended. But... it's focused on Lisp.<p>It describes the thinking behind an implementation of OOP for Lisp, and along the process reveals parts of the mental journey to both Smalltalk and CLOS.<p><a href="https://en.m.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol" rel="nofollow">https://en.m.wikipedia.org/wiki/The_Art_of_the_Metaobject_Pr...</a>
OOP implementation in Next Generation Shell was inspired by CLOS but it's way simpler.<p>Defining a type: type MyType.<p>At any point one can declare method: F myMethod(..., mt:MyType, ...) some_code()<p>Anything defined by F is automatically a multimethod. When invoked, all methods in the multimethod are searched bottom up. The first one where the call arguments match the parameters (by type, with inheritance) is invoked.<p>That's roughly it.
One thing bad is the word 'class'. What it is supposed to even mean? It was some fancy concept by stupid Normen when defining Simula. My Simula teacher said that you could just translate it as "design" as in "design of car and its implementation".<p>Anyways Python's "class" is even worse:<p><pre><code> class c: a=10
print c.a
c.a=13
print c.a
</code></pre>
I cannot think any English word to replace the "class". The word I am thinking of could be translated as "box". "Box of things and improved versions of it".
> Instead of instructions like in imperative programming (and modularizing it with functions), your program is a set of entities talking to each other and collectively achieving the required goal.<p>So it looks like the author discovered a key characteristic of OOP which many languages including Java, support.