This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-26
Channels
- # aws (1)
- # beginners (50)
- # boot (32)
- # chestnut (2)
- # cider (14)
- # clara (23)
- # cljs-dev (131)
- # cljsrn (44)
- # clojure (133)
- # clojure-belgium (3)
- # clojure-denmark (4)
- # clojure-dev (6)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-russia (95)
- # clojure-spec (59)
- # clojure-uk (14)
- # clojurescript (157)
- # cursive (26)
- # data-science (1)
- # datomic (160)
- # devops (5)
- # dirac (80)
- # emacs (2)
- # graphql (2)
- # jobs (2)
- # lein-figwheel (1)
- # lumo (9)
- # off-topic (151)
- # onyx (2)
- # parinfer (2)
- # pedestal (5)
- # perun (2)
- # re-frame (60)
- # reagent (3)
- # remote-jobs (1)
- # test-check (3)
- # uncomplicate (11)
- # yada (1)
the chapter on datatypes, protocols and interfaces in Programming Clojure 3rd edition is excellent
it used to be used to repel moths from clothing, mal = moth, ört = herb, malört is the swedish word for wormwood…might be reiterating things, was too tired to read the last hundred messages : )
so far as i know the only place in the world you can get this divine ambrosia is Chicago.
idea for a programming competition: first place is a bottle of malort. last place is 2 bottles of malort.
I quite like Malört. Hard to find tho’… and it’s been a while since I last drank any…
(but then, I quite like bitter drinks in general)
Seems to be a fad here (Chicago).
I have never had it though.
I do like a gin and tonic. I am guessing that it is quite a bit more bitter though.
Ever had Angostura Bitters? There’s been a recent trend in cocktails to create drinks based on those (and other, similar, bitter tasting additives).
I’m a fan of fernet and compari (there’s a drink with a terrible name that mixes the two - a ferrari)
two very bitter italian beverages
there’s a question?
There’s two questions (at least): 1) does Clojure have any OO features? (yes) 2) are some OO features good/useful (vs is OO just bad all round)? (yes) 🙂
i'd like to find a bright line between oo and fp a la clojure. best candidate i know of is to think algebraically - a clj protocol is an algebraic signature, and algebras are always polymorphic, just change the model.
haskell can claim to do fp without OO, I don’t think clojure can do so at all
it has OO fundamental in its design and its implementation
howsabout "Clojure and OO languages have some features in common"? but i wouldn't call those oo features, since a non oo language can have them.
they can have something similar
something equally useful.. .but not that feature
@noisesmith that's an interesting assertion. can you elaborate? i like thinking of clj as oo-free.
you’re making bizarre counterfactual arguments about something that could exist but isn’t actually available
clojure protocols are OO, they allow late binding via extension
clojure collection functions are all built on protocols (or even more OO, underlying java interfaces)
clojure functions are objects with an invoke method
and protocols (like the interfaces they build on) are abstract classes
each clojure collection is an object of a class implementing various interfaces and protocols describing immutable data
defrecord
is pretty solidly an OOP construct — or do you disagree with that?
clojure includes clojurescript, whose host is not oo. so oo is not essential to clj implementation.
Assembler is not OO but you can compile OOP languages to it.
cljs has defrecord, cljs has protocols…
@seancorfield i understand why it's natural to think of defrecord in oo terms. but i don't think it's essential to do so. a record is just a datum that satisfies a protocol. that does not make it an instance of an oo class.
@mobileink the dispatch system in clojure allows it to be an instance though
i take isa?
in that case to mean "is a value that satisfies the protocol", rather than "is an instance of a (first class) class".
@mobileink then what is satisfies?
yeah, and we have no such thing as the first
we have classes and instances, we don’t have types
not in the “strong typing” sense, the kind you can verify anything about
Most of the comments here about OO and Clojure are about implementation details and as such are irrelevant to the language semantics.
clojure has no formal language semantics apart from implementation
and it’s not just implementation, it’s also the constructs available in writing clojure code
we don’t have types, or anything that behaves properly like one
we do have classes, instances, and implementation of interfaces by those classes
put it this way: the conceptual structure of Clojure is oo-free. That fact that one host env is oo does not affect that.
nonsense
many of clojure’s core concepts are OO - it’s not a language that is designed to hide or abstract over its host platform
contrast eg. scala
I think 'implementation' there is being used in two ways. What you really mean is semantics are defined by the reference implementation behavior. Not the actual code
Second, of course it is not 'just' implementation - that's why I used 'Most'
if you have evidence that clojure is meant to hide its platform’s implementation I’d be fascinated to see it - eveyrthing I’ve seen both in the words of RH and in the actual design of the language indicates that it intentionally exposes the host platform as something end users of the language should use
I say nonsense to your 'nonsense'! 😉
I agree, everytime I have to interact directly with Java, I have to start thinking like a Java programmer again.
I never said anything about it 'meaning to hide' it's platform. That is irrelevant
from "Rationale": "Clojure is the language, JVM the platform". but the jvm is just one of many possible platforms. Clojure is not "a better way to do java".
if the language semantics directly include direct interaction with the host platform as a core construct, I can’t see how you can call the implementation platform an irrelevant detail in the language
interop is easy to use, and often necessary, and it’s meant to be so
So, you implement it on something totally different - maybe some underlying C based platform or CL platform. It would still be intended to work with that, but those wouldn't be OO.
or js - but hey, we still have records and protocols that operate in an OO way in cljs
And, generally, you can go days (I can) without knowingly doing any interop or using any of the OOish aspects
despite js not being that sort of OO language at all
You're just making my case...
not sure who called " the implementation platform an irrelevant detail in the language". but i might go there. Clojure's interop capabilities are amazingly generic.
@mobileink I was responding to this https://clojurians.slack.com/archives/C03RZGPG3/p1498506419798336
e.g. (.foo bar)
works for both clojure and clojuresscript. that looks like an anstraction over platform to me.
In many projects it would be very difficult to ignore the underlying C platform of Clozure Common Lisp. I don't think that makes it reasonable to say it is basically C with some sugar.
That is still true
@roberto: agreed. but it's about as close as can get imho, especially when you're trying to balance performance. clojure has always been very prsctical.
@jsa-aerial I didn’t say clojure is java with sugar, that would be silly. But I am saying that clojure is an OO language because it directly uses constructs from the platform not only in its implementation details but the surface that it exposes to a programmer using the langauge.
But by design it could be implemented on top CCL and then you would not have an OO platform.
it even makes its own OO constructs that the platform lacks - eg. multimethods and proxy
I didn't say it had no OOish stuff!
I don't even know if it makes sense to call mutimethods OO in any typical sense
@noisesmith maybe we're all working from different ideas about what "oo"means. i think that's part of the problem - there is no widely accepted formal model of oop.
clojure doesn’t do typical OO, it does the good kind of OO - which often doesn’t look like java and c++ and that’s fine, but it’s still OO
Actually, that is undoubtedly true! @mobileink
Maybe for you it is
multimethod is OG OO - “give this thing a message, it will know how to respond”
Is part of the problem here that when people hear “OOP” they think of “Java”?
how is that object 'oriented'? You don't even need an object for this
(or their nearest semantic equivalent based on their experience)
I think https://clojure.org/reference/datatypes is the best summary of Rich's thoughts on this
@seancorfield bingo. oo is so undefined that our only real option is to fall back on our experiences. the nice thing about fp is that it has a widely accepted formal model (lambda calc, turing).
I an not quoting Rich but my suspicion is that he would say Clojure is an FP language that has some features common in OO (and is firmly in opposition to others, like concrete inheritance and encapsulation of data)
Also it's designed to have good host interop so is flexibly harmonious with the host, leveraging what it can there re OO
To quote the man himself:
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.
@alexmiller one thing from that passage puzzles me: "The abstractions are specified by host interfaces, and the implementations by host classes." how are the abstractions specified by "host interfaces"?
@roberto - thanks for that, I could have saved a lot of typing if I’d just looked that up and quoted it first
but even the OO developers disagree with Alan Kay on that. Had a discussion with some folks last week and they totally dismissed Kay’s definition.
@mobileink here he literally means Java interfaces
(in cljs those are specified as protocols)
The Clojure compiler and runtime are almost completely ignorant of the actual concrete classes implementing those interfaces
Other than places where they must be constructed
Which is how you can swap in new data structures and they all know how to conj, assoc, etc
hmm, i think of the abstractions as things like map
, which are part of the language. what am i missing?
That doesn’t make Kay wrong, nor those developers right.
map
works because of the sequence abstraction.
@mobileink I don't think map is an abstraction that he's talking about
Rather stuff like sequences
I wasn’t say Alan Kay is wrong. Was just trying to hint at the incongruencies in the OO community and I get the impression many have not researched Alan Kay’s original intent and just get carried away by the buzz words introduced by vendors in the early 90s.
In Lisp map would work on lists. In Clojure it works on sequences, which are logical lists (via the sequence abstraction)
ah. he means the abstractions declared/defined by the host env? which clj in a sense abstracts again?
Abstractions defined by Clojure
Whose implementation is primarily Java interfaces on the jvm
And protocols in ClojureScript
"define" might be better
Many more words in particular areas
That's a stupid feature
A lot of Java 9 is 'stupid'...
It starts to make sense when you hear Goetze explain how they arrive at those decisions
@alexmiller man, why didn't say so?? that stuff should rilly be in the official docs.
No, I totally get how they ended up there
there is no contradiction is something both making sense and being dumb.
I think their main focus now is on the JVM and how they can add features to it. The language is secondary at this point I think. Which makes sense. The JVM languages will improve thanks to the changes they are introducing.
@jsa-aerial i do that all the time!
Yeah, so do I. But I'm not controlling the development of a key piece of technology...
what’s really dangerous is making sense, but dumbly “for every complex problem there is a solution that is clear, simple, and wrong” - Mencken