5 ms·
It was strange at the time to put a lisp on the king of OOP languages, given all the lispers so fiercely dismissive of OOP, but never has a lisp language enjoye
by JimmyRuska 3y ago
It was strange at the time to put a lisp on the king of OOP languages, given all the lispers so fiercely dismissive of OOP, but never has a lisp language enjoyed such a huge ecosystem of libraries available.
I use Erlang as my main language. I like that so many languages have lisp alternatives, so I can just rename the most common function calls to what I'm used to, and feel mostly at home between the different languages, other than different syntax for some data structures like maps.
- pjmlp 3y agoIt is only strange for those that don't know Lisp, given CLOS, LOOPS, and "The Art of Metaobject Protocol", whose ideas gave birth to CLOS.
- koito17 3y ago> given all the lispers so fiercely dismissive of OOP I don't know where you are sampling your Lispers from. The only people I see blindly opposing OOP in Lisp communities are people who either (1) don't write a single line of code, or (2) know nothing about Common Lisp, the various Schemes with their own object systems, or even pause to consider what inspired Clojure's `defmulti` (spoiler: a Common Lisp library that used the Metaobject Protocol to allow for arbitrary dispatch in generic functions). With that said, I do notice the Clojure community tends to be more against OOP than other Lispers, which I find golden because, again, the core language has things directly inspired from MOP libraries, and things like "atom watchers" are trivially an :AFTER method in CLOS, and so on.
- KingMob 3y agoI'm guessing it's because the creator, Hickey, is anti-inheritance, and the Clojure community as a whole is uncritical of him. I actually agree that inheritance can be tricky, but is still needed sometimes, especially for interop. Elsewhere in Clojure, he makes his preferences the defaults (like immutability over mutability), but always has an escape hatch when necessary. For inheritance, there's no escape hatch. Best you can get is a crippled proxy. Another issue is how mutable fields in deftype work. Mutable fields can only be mutated from class methods (protocol fns in Clojure parlance), so you can't use outside helper fns. You can add helper fns to your protocol (like an interface), but that's a public signature, not generally meant to have internal-only fns. The joy of interop with Java from Clojure is occasionally getting to discover that there's no good code reuse in certain situations with a family of classes, and realizing, oh yeah, this is why we wanted inheritance in the first place.
- jabradoodle 3y ago> For inheritance, there's no escape hatch. Best you can get is a crippled proxy You can use gen-class here. Granted complex Java interop trends toward a point where it becomes easier to write and expose a Java library; the option is there though.
- KingMob 3y agoHmm, good point. I always forget about gen-class, because I've been burned by AOT compilation too many times.
- pjmlp 3y agoIf he was anti-OOP he wouldn't have added most of CLOS infrastructure to Clojure.
- KingMob 3y agoIf he was pro-OOP, why not add all of CLOS?
- pjmlp 3y agoEasy, first of all, if he was anti-OOP, he wouldn't have added any of it. Secondly, what he added is enough for doing OOP in Clojure, in fact, very few OOP languages support everything that CLOS allows for, and that doesn't make them less OOP. OOP !== Java 1.0
- KingMob 3y agoAll kidding aside, it's obvious that Hickey is not entirely anti-OOP. But then, that's not what I said; I said he was "anti-inheritance". And my complaint is that unlike many other places in Clojure, there's no easy escape hatch for inheritance when you need it. `proxy` is limited, and `gen-class` involves AOT compilation, which can cause various problems.
- lispm 3y ago> given all the lispers so fiercely dismissive of OOP note though, that Lisp was 1994 the first officially standardized object-oriented language.