5 ms·
Clojure, or maybe all these related Rich Hickey talks transformed my attitude towards systems programming. Before that, the Unix philosophy. But perhaps I can't
by pvdebbe 10y ago
Clojure, or maybe all these related Rich Hickey talks transformed my attitude towards systems programming. Before that, the Unix philosophy. But perhaps I can't say that the Unix philosophy changed my career because I adopted it very early in my programming and way before any career established.
Sadly, Clojure has left me in a position where Python + Django in my day work disgusts me with its mutability and unnecessary OO semantics, but I don't have much choices in my area. Ignorance can be a bliss sometimes!
- TurboHaskal 10y agoClojure has mutability and a lot of its idiomatic abstractions are object oriented in nature.
- pvdebbe 10y agoBut exactly. The so-called OO languages are worse at the key tenets of OO paradigm: polymorphism and message passing. I didn't even attempt to clarify that in my original post so forgive me for that.
- JulianWasTaken 10y agoI'm a sizable clojure fan (and a long time Python developer) but I'm not sure where you'd say Python fails at polymorphism or message passing too strongly. Interfaces/traits maybe (z.i is quite crusty) but it's just as good at polymorphism. Mutability though yes -- hope you're aware of https://pyrsistent.readthedocs.io/en/latest/ https://pyrsistent.readthedocs.io/en/latest/ I use it in every project I write.
- pvdebbe 10y agoYes, I've been hasty to write sloppily today. One thing that is not perfect is the way Python treats classes; the mechanism is very much like in Java or C#. Multiple dispatch requires some handiwork, although it's not half bad in a highly dynamic (so many things are first class in Python!) language. It kinda isn't Python's fault but there you go when trying to introduce concepts to fellow developers not in the most usual python guidebooks. And a part of the problem is Django, which is nice and all, but entails some highly unpythonic design choices and people around here take Django's way as gospel. Pyrsistent is great. But I'd rather Python 4000 or something would go the way of scala or swift where you have immutable values by default and mutable values only when you specify it.
- hellofunk 10y ago> a lot of its idiomatic abstractions are object oriented in nature This is a curious comment, and I'd like to hear some elaboration. I used C++ for years, then 2 years as a full-time Clojure dev, and I don't see any OO parallels in Clojure at all.
- pvdebbe 10y agoA couple comments. * clojure protocols map to interfaces (abstract classes for C++ folks) * one can define records that satisfy protocol(s). This is one way to do OO in clojure, happens to map to the underlying JVM mechanisms for JVM optimizations to kick in. * Gamma et al., Bloch and many others tell to prefer composition over inheritance. Clojure makes this guideline easy to follow. * overall the OO leaders also recommend making classes "value classes" (everything immutable; smart copy semantics; etc) as often as humanly possible. * Multimethods allow arbitrary dispatch (most versatile kind of polymorphism) and there is also a faster method when you only want to dispatch by protocols (the (sadly) 'usually' only way to dispatch in most OO languages) that reuses JVM notion of classes and interfaces behind the curtains. * What you don't get is encapsulation, (and many, a great many authors cite encapsulation to be the definite trait of an OO language,) it can also be argued that immutable values do not need encapsulation per se. A value should be able to stand on its own, convey the semantics it needs & so on..
- hellofunk 10y ago> a great many authors cite encapsulation to be the definite trait of an OO language Yes this is what I was referring to, Clojure is not OO in the way that many think of OO. But your other points are right on.
- pvdebbe 10y agoBut what exactly is achieved with information hiding, hmm? :) Now there forms many schools of opinion, and in many of them it suffices to have data immutable and value-like, and suddenly it doesn't matter if the information is hidden into opaque memory addresses or not.