So why Clojure? That is probably the question I hear the most from other developers when I tell them I mostly work with Clojure. Well that or, ‘What is Clojure?’. Well, if you’re on of those developers and are curious about this cool Clojure language then here is a non exhaustive list of answers to, Why Clojure?

Clojure is Powerful

Using Clojure sometimes feels like a scripting language in that I’m getting a lot done with very little code. In fact there is a project called babashka which aims to make Clojure a scripting language.

Clojure provides a rich core library of functions that are used to assemble your own programs with. Once you pick up a few like map, filter, reduce you will quickly start leaning on them a lot. I often find myself missing these core functions when I’m using a different language.

Clojure allows for powerful meta-programming if you’re keen on that. Clojure being a Lisp, ppppextending the language is fairly easy with macros. Asynchronous programming in Clojure is provided by a project core.async is a library built with macros, not changes to the internals of Clojure itself.

Embracing the Underlying Machine

Clojure is a hosted language. It runs on top of an existing run-time. The Java Virtual Machine is the most typical, if someone doesn’t specify you’re safe to assume JVM. There are also JavaScript and CLR implementations of Clojure too. Embracing the host run-time is a really powerful benefit as it enables Clojure to take full advantage of tooling and libraries written for that host.

For example, Clojure on the JVM can use any Java library directly via interoperability. Furthermore tooling for the host language will still work with while running Clojure. Clojure-Script has interoperability with JavaScript in the same way Clojure does with Java.

Clojure chooses to embrace the underlying host. You can call Java code directly via interoperability.

;; Clojure works with Java
(.getTime (new java.util.Date))
1669927706804

Java has a extremely large and well supported ecosystem. It would have been silly for Clojure to ignore it. The same can be said for the other hosts too. As a mate of mine once said, all the good bit of Java without the language getting in the way!

Developers Love Clojure

Okay, maybe this point is a little biased on my part but bear with me!

Every team I’ve worked with which used Clojure have loved it. To date I’ve used Clojure in four different professional organisations. It was very well received in all four by the development teams. Even or maybe especially in those teams which were making a transition from vanilla Java.

When working with Clojure it is very common to have a REPL, read evaluate print loop, running while coding. This lets you isolate and run bits of code from within an IDE. The REPL is fantastic for quick experimenting or hacking away at a problem.

I find that developers love the flow and short feedback loops the REPL enables. Teams value the concise and clean code they were able to produce. The functional programming elements and emphasis on reducing the amount of state seriously simplified our code. Clojure feels like it allows you to get a lot done with few lines of code.

Clojure’s sensible defaults

I find the choices made by Rich Hickey to have been extremely well thought through. Leaning into functional programming whilst remaining a pragmatic language is fantastic.

Immutability by default strongly encourages functional patterns and simplifies code espechally once concurrency comes into play. You don’t need to keep track of what may have changed a property on this object because they can’t change!

Clojure is an extremely stable language with hardly any changes to the core of the language between major releases and that is a testament to the amount of time and effort the folks working on the language have invested into it.

Clojure will make you better at Programming

Okay that is a big claim. I can only speak to my experience and what others have told me about their experiences. I’ve worked with many developers at different stages on their Clojure journey. I frequent story I have heard is that, once Clojure clicked, it made them better coders in general. That is my experience too.

It might be too much to say that was all because of Clojure. For many of the above developers, and myself, Clojure was the first functional programming language we’d used. That may or may not be the case for you. Thinking functionally is powerful and you’ll grow to love it if you don’t already.

Conclusion

So there you have it. Some of, but by no means all, the answers to, ‘Why Clojure?’.