Hacker News new | ask | show | jobs
by potency 1670 days ago
What is Clojure's main selling point?
7 comments

If you have an hour spare, probably the best way to understand Clojure's main selling points is to watch this talk: https://www.infoq.com/presentations/Simple-Made-Easy/

InfoQ list the Key Takeaways as:

- We should aim for simplicity because simplicity is a prerequisite for reliability.

- Simple is often erroneously mistaken for easy. "Easy" means "to be at hand", "to be approachable". "Simple" is the opposite of "complex" which means "being intertwined", "being tied together". Simple != easy.

- What matters in software is: does the software do what is supposed to do? Is it of high quality? Can we rely on it? Can problems be fixed along the way? Can requirements change over time? The answers to these questions is what matters in writing software not the look and feel of the experience writing the code or the cultural implications of it.

- The benefits of simplicity are: ease of understanding, ease of change, ease of debugging, flexibility.

- Complex constructs: State, Object, Methods, Syntax, Inheritance, Switch/matching, Vars, Imperative loops, Actors, ORM, Conditionals.

- Simple constructs: Values, Functions, Namespaces, Data, Polymorphism, Managed refs, Set functions, Queues, Declarative data manipulation, Rules, Consistency.

- Build simple systems by: Abstracting (design by answering questions related to what, who, when, where, why, and how); Choosing constructs that generate simple artifacts; Simplifying by encapsulation.

So Clojure is a language that embodies these principles in its design. It's a Lisp, which means that all code is constructed from a very regular expression syntax that has an inherent simplicity and can be quickly understood. It's a functional programming language that provides exceptional tools for minimising mutating state, and it favours working with a small set of data structures and provides a core api with many useful functions that operate on them.

I'd say the result is getting a lot done with a small amount of code, minimal ceremony, true reuse, and the ability to maintain simplicity even as your system's capabilities grow.

There's also transcripts of this and other Rich Hickey talks available: https://github.com/matthiasn/talk-transcripts/blob/master/Hi...
A really well thought out Lisp-1 that runs on the JVM, in the browser, in node as well as the CLR and BEAM.

It is hard to go back to other languages once you appreciate its simplicity.

Sibling provided a good overview of philosophy. Practically it offers Lisp goodness, jvm/js interop and a well-designed set of persistent collections everyone and their dog uses, part of the reason why clj libraries tend to compose very well. You get some stunning mileage out of the thing.
It's very good and straight to the point about transforming data. The central data structures (maps, keywords, vectors) and excellent languge + standard library centered around those, combined with interactive iteration at the REPL, make for a rewarding development experience when you can just try stuff. Since most things are immutable and passed around as data, you can easily rerun things at the REPL with high confidence that objects in your data aren't being mutated.
It's lisp on the jvm.
Not writing Java (although you do have to do lots of interop with Java).
It's true it's "not writing Java", that's true for every language besides Java! But the second part is definitely not true. First, you can very much use JVM Clojure without touching Java, I've done so many times. Secondly, you can use ClojureScript which cannot even do interop with Java since it "compiles" to JavaScript and doesn't run on the JVM. Thirdly, you can use Babashka to run Clojure code with GraalVM and SCI instead.

Many options exists to not having to touch Java when you use Clojure, but I guess it's hard to kill old memes?

If you are writing toy programs in your mom's basement sure but every real world clojure project I have work with had to use Java libraries.

When I said 'not writing Java' I was obviously talking about the JVM.

> If you are writing toy programs in your mom's basement sure but every real world clojure project I have work with had to use Java libraries.

That's OK, most real world Clojure and ClojureScript projects I've worked on didn't had to use Java libraries, maybe 10% of them had to have Java code or used Clojure-wrapped Java libraries. Everyone's experience is different :)

> When I said 'not writing Java' I was obviously talking about the JVM.

Yeah, that's not super obvious as normally people consider Java the language to be something else than JVM the runtime.

I've seldom had uses for Java interop, once in a blue moon. An exception is FP math functions and constants, using those from java.Math via interop instead of having a native math library has been the Clojure way (but seems getting a native wrapper in Clojure 1.11, clojure.java.math).
Then using the JVM to start with isn't really the cleverest decision.