This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-23
Channels
- # announcements (3)
- # babashka (68)
- # beginners (297)
- # calva (13)
- # cider (4)
- # clj-kondo (8)
- # cljs-dev (10)
- # cljsrn (26)
- # clojure (100)
- # clojure-europe (4)
- # clojure-germany (1)
- # clojure-italy (9)
- # clojure-nl (5)
- # clojure-spec (9)
- # clojure-uk (41)
- # clojurescript (69)
- # conjure (70)
- # cursive (44)
- # data-science (20)
- # datascript (2)
- # datomic (55)
- # emacs (1)
- # exercism (3)
- # graalvm (2)
- # kaocha (11)
- # leiningen (6)
- # meander (9)
- # mental-health (1)
- # off-topic (73)
- # pathom (6)
- # pedestal (1)
- # re-frame (3)
- # reagent (52)
- # reitit (8)
- # rum (39)
- # shadow-cljs (152)
- # spacemacs (10)
- # tools-deps (28)
- # xtdb (5)
I shared the following in my network, "Clojure - as fast as Java, as productive as Python" A friend came back saying "So is Kotlin". How do I respond to this? It is so hard to explain a LISP to a non-LISPer.
Do you really need to respond to that? I assume that the friend knows Kotlin but doesn't know Clojure, and you're the other way around. It will be really hard to reconcile such different areas.
I want to. This is my one shot at making him interested in Clojure. If I say the right thing, that is.
I really, really don't think coming up with a catchy one-liner is a good way to do it. The best way, in the long run, is to make yourself familiar with Kotlin.
I agree with your line of thought. I can't really change someone's mind. Only if I can plant a little bit of curiosity...
Clojure is dynamic, data oriented and has a true REPL: https://www.youtube.com/watch?v=r8YKC7Qugm8
Many people became curious about Clojure because of Paul Graham, isn't it? And now Uncle Bob Martin.
The regular answer of non-LISP people to that: "Dynamic? Hell no. Data oriented? So is Java - look at those ArrayLists and all those DTO classes! True REPL? I have never needed anything like it, sounds irrelevant."
@U011LEAEURE Thanks! That's a nice video.
I fully agree with @ p-himik.
I think getting them to watch a Rich Hickey talk is probably the best way. If "Simple Made Easy", or "Are we there yet" doesn't spark curiosity, then I dunno if it's worth it
DTO is not data. Java Collections are, but mutable, no destructuring etc. Java and Java libs aren't oriented around Collections the way Clojure is.
The only other way I see is to actually learn Kotlin to a non-trivial depth.
Really? 40 minutes is nothing, and you don’t need even to be typing. I watched talks while doing dishes (not optimal, you have to rewind with wet fingers many times).
I used to work in a place where about 80% of the developers didn't know anything else but Java, maybe some JavaScript. They would never even look in the general direction of something different. Unless, maybe, if it was an direct order from the management. "A 40 (!) minute talk?! I don't have time for that. Go away, let me grind in peace."
I do a lot of Java like Clojure 😋 Streams, maps, collections, lambdas etc. Avoid domain classes, state, mutation... "drag a lot of them about halfway to Lisp"
I make all classes immutable. All params in constructor. No setters most of the time. Only builder classes are mutable. Worked for me for years.
Sure, it's getting gradually better. Alas, so many companies are stuck with legacy projects on ancient Java versions.
I tend not to make domain classes at all. Use maps. Variations of the builder pattern yes, that is the only way to create DSL in Java AFAIK.
Most of the time... query -> maps -> transform via streams -> JSON
Also, you need utility methods for maps to avoid boilerplate... But stream collectors can do a lot.
Unfortunately, Java took the Records + Inline Classes road... It could have been closer to Clojure if they added literals for collections, as Collections creator Joshua Bloch suggested: https://twitter.com/joshbloch/status/610860387672662016 https://twitter.com/joshbloch/status/440638067292909568 https://twitter.com/joshbloch/status/777887190219104256
Java will probably surpass Kotlin eventually... Clojure is different mindset and experience.
Yeah, I feel Kotlin is mostly syntax sugar, but I am no expert. They have added continuation passing I heard. With Java, the good thing is an IDE can generate most of the garbage for you. But it still hurts readability. Well written Clojure is more readable because it can be so concise.
Recods will have destructuring and you will not have to write equals, hashcode, tostring, constructor, getters etc. Also, they are "immutable" (everything is final). But that is still static and, IMO, inferior to maps.
Agree with the general thought that you will not be able to convince anyone of anything 😁 The only way that I went close to adopt Clojure in my Java shop was because my manager was into it. All my enthusiasm went into that but eventually they shut the project down and the code sits to rot in the repositories and now we are back to Java (and Go)
If you want to convince someone of any tool the best way I've found is to make a sizeable Apples to Oranges comparison for something you have to do
its easier to do in kotlin than clojure since kotlin you can just translate existing code and say "hey isn't that prettier"
but to show the benefits of clojure in a way that will rhetorically stick you need to show that the alternative model of programming leads to simpler stuff in aggregate
its important to remember that social and internal pressures will make "why am I using clojure" an active thought for the entirety of a project for most people "talked into it"
Yeah that comparison would never work, I went very very close to get a service completely on me two weeks ago to show how fast I can go with Clojure - that would change minds
I agree with "making them curious" -- if you can't do that, you can't persuade them in any way (in general). There's an element of Blub here: Clojure looks very different to all the languages they already know (no matter how few or how many) so they can't tell from casual exposure whether it's "better" compared to their "home" language.
What worked at our place was for me (the initial Clojure enthusiast) to solve a problem that was well-known to the company and to the other engineers. Then I could show them "here's the solution in X and Y" (existing tech that had been used) and "here's the solution in Clojure". The Clojure code was much simpler and shorter and, because they knew the problem space well and had read the existing solution code, it spiked enough curiosity for them to want to at least try Clojure.
But make no mistake: learning Clojure well enough to use it productively at work instead of existing tech is hard and takes time. So "selling" something as alien as Clojure to individuals (and to especially to companies) is a tough sell.
I was lucky because management trusted me to make tech stack decisions for the whole team and they were supportive of training, books, and a period of (much) lower productivity while the engineers cross-trained.
Ultimately, both members of my original team moved on after a few years of Clojure: one to an all-Clojure shop and the other to an all-X/Y tech shop. The former to be fully immersed and avoid our legacy X/Y tech and the latter to get away from the new alienness of Clojure and go back to their comfort zone in X/Y tech.
But folks like us get curious and then excited about Clojure and want to "spread the word" -- and as @UJRDALZA5 has found out, not everyone is as receptive to the word as we might like 🙂
@UJRDALZA5 I would first think about your friend. Are they asking because of skeptical curiosity or are they just trying to deflate your idea balloon for fun? If it's the former, try responding with a question to ask why they think that. Then you can either reach agreement that both languages do fit that, or you can show examples of how Clojure embodies it more. I think the trick is turn it into a multi-directional, open conversation and not just listing cool Clojure concepts like a soapbox preacher. 😄
Also, if I may suggest...don't go for the "let's have a separate team that proves everybody is wrong" approach. It never works as well 😄
He is a good friend but he likes to stick to his own tools (so am I). @U8WFYMFRU It is the former.
In that case I would definitely aim for an open-conversation to learn more about both languages than trying to prove them wrong.
Kotlin is nifty! It’s hard to win an argument if you aren’t open to other cool things. And there is a lot that is legitimately nifty and great about Kotlin.
My path to Clojure actually started because I was investigating Kotlin’s coroutines mechanism. I was so burned out on Android client that I didn’t actually want to play around with it, but I felt the need to brush up on it anyways
that led me to wanting to read up on CSP, which led me to just watch some rich hickey talks, and then I just wanted to play around with clojure because the design discipline sounded so much more fun than the OO hell I’ve been stuck in for so long
I agree that Kotlin is really nice. I try to learn a new language every year or two per The Pragmatic Programmer and Kotlin was the most recent one I picked up I think... I didn't get very deep into it but it impressed me as a "better Java". I think if I couldn't do Clojure, I'd probably be able to survive if I had to use Kotlin 🙂
kotlin has a lot of the functional stuff that clojure has
but it doesn’t have the data oriented design or the dynamicism
Apologies for ignoring all the comments above but ‘as productive as Python’ in my opinion is utter exaggeration. When I’m having hard time figuring out things in Python, I turn to Clojure to wind my head off, have fun, solve the problem and get a proper mindset.
Yes, but to someone only familiar with mainstream stuff, I felt Python is a good analogy. Maybe Ruby too, but Python is more popular in my circle.
I think the response should be short yet catchy. Like an elevator pitch. Someone oblivious to the virtues of a LISP will have a very short attention span.
^ Clojure needs a certain level of patience and open-ness to-click IMO. Doubly so for people who don't already "get" what LISPs are about.
Yes, I agree. Have you seen Inception? All you have to can do is sow a little bit of curiosity. It may work, it may not. But that's the only way.
On a similar topic to hindol, I'm talking to a friend about Clojure as well. It's one thing to say it has a pretty minimal syntax it's another to show it so I created https://gist.github.com/eccentric-j/9741849e6c3933a5f4f9439bcb80566e. I think that's most of it. Is there anything critical I'm missing?
I myself found for
in Clojure very surprising (it returns a sequence). And loop/recur?
Believe it or not, I did the exact same thing a few months back. https://gist.github.com/Hindol/727eb69e9943b371e66902c19960fd0c
Hmm maybe at the bottom I could use defn as an example of how it fits within the syntax described above. My goal is not to show how to use Clojure as there's plenty guides (including yours) for that. I just want to show how structured\consistent the syntax is.
It's the first page of several, walking beginners through the language...
The REPL guide is really good too https://clojure.org/guides/repl/introduction
(seven pages)
The http://clojure.org site is updated almost continuously https://github.com/clojure/clojure-site/commits/master
@U8WFYMFRU Maybe let
too. Your friend might ask about variables.
I was looking at that the syntax guide the other day. For the context of my discussion I want to show how learning a few syntax rules nets you the whole language where as the syntax changes for every type of thing you do in Python.