How is OOP implemented in Lisp? Is it implemented correctly as in Smalltalk and Ruby, or incorrectly like in C++, Java and most other so-called OOP languages.
CLOS (common lisp object system) is definitely on the correct side. Alan Kay (creator of Smalltalk) himself is fond of it.
Here is his opinion on the book I mentioned:
"the best book anybody's written in ten years", and contended that it contained "some of the most profound insights, and the most practical insights about OOP"
Anyone that wants to argue with me about OOP in the real world never seems to have any good reasoning. It’s just “I thought we didn’t need to know and use classes anymore”.
You didn’t NEED to use them ever but that doesn’t mean that classes, inheritance, and protocols aren’t super useful.
Some languages force OOP everywhere but either way, when they aren't implemented correctly, there is a loss of the full benefit of OOP. I posted a link to Alan Kay's reasoning nearby.
Lisp had at least two competing OO ideas (loops and flavors) then common lisp got the CLOS (Object System). It's very much not like cpp/java.. and yeah much more reflexive, like smalltalk. It's also much more generic, via multiple dispatch. So methods live between classes and can be specialized in any which way.
you have method combination to override existing methods (object decorators in a way), and then the builtin metaobject layer to adjust the meaning of any implementation decision made by the standard.
It's probably second to clojure among lisps in terms of professional use. But a distant second. Lisp's biggest strength is also perhaps its largest barrier to wide spread adoption. Because everything is possible, including creating entirely new syntax or paradigms -- you can make your own OO lisp in like 20 lines of code -- nothing is standardized. So every codebase is a bit like learning a new language.
The Common Lisp Object System (CLOS) faced some interesting design challenges, particularly given the generally applicative nature of the LISP family. It grew out of earlier research on LISP object systems, such as Flavors, and arrived at kind of an uneasy marriage of the class-based approach and more of the prototype-based approach that (to the best of my knowledge) originated in Object Lisp and lives on today in JavaScript. CLOS features classes and inheritance, but I would argue its generic functions, multimethods, and especially method qualifiers set it apart from the majority of other object systems in any language.
The metaobject protocol is exactly what it says on the tin: an approach to making it possible to roll your own object system that, on one hand, would integrate with CLOS in predictable ways, and on the other, would provide programmer-defined constructs and semantics to CLOS. Again, to the best of my knowledge, no Common Lisp ever fully implemented the MOP, but significant subsets of it appeared in various Common Lisp implementations, and an attempt at creating a unified compatibility layer appears here.
It's kinda trippy. It's specified object system is neither class-based nor prototype-based but uses something called generic functions instead. R's most common object system uses this method as well.
Interesting read. To quote: "OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.". Interestingly, microservices embody these concepts very well (assuming they are well-built I guess).
My take on it is that C++ and Java and some other languages were trying to be performance pragmatic. So they allowed primitives and they swapped "message passing" for "function call". Today it seems impure enough, but in the late 80's early 90's, this was the difference between a research project and something people would use in the "real world".
I don't understand what you are referring to there.
I think the key parts of that article are:
“I invented the term object oriented, and I can tell you that C++ wasn't what I had in mind.” —Alan Kay.
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.
He made these statements in 2003.
I think a good way to understand what he is saying would be to try Smalltalk. You could use Squeak or the newer Pharo.
24
u/Laugarhraun Dec 20 '22 edited Dec 20 '22
My Art of the meta-object protocol disagrees.