Is Clojure the only language you need?

The question

Clojure is a hosted programming language. This means what you wrote in Clojure will run in an environment of another language.

The most popular implementation of Clojure turns Clojure code into Java bytecode that runs on Java Virtual Machine.

Another popular implementation is ClojureScript. And its compiler turns your Clojure code into JavaScript.

And there are a lot of other implementations.

If you can run Clojure where Java or JavaScript runs, can you learn Clojure and conveniently use it in ALL areas of software development?

Well, no. There is no silver bullet.

But can Clojure be the only language YOU need? Yes, if you write software in areas where Clojure proved to be good.

Backend

Here Clojure fits perfectly. Running on JVM, with its immutable data structures and built-in concurrency support, Clojure is very good at dealing with simultaneous connections and processing big amounts of data.

One of the main examples of a production Clojure backend is a Nubank. It is a Latin American digital bank that used Clojure so heavily, that in 2020 they decided to acquire the Cognitect company that develops Clojure.

On job boards, you can find backend Clojure roles in advertising or sports data processing.

FrontEnd

FrontEnd is also an area where Clojure fits, particularly ClojureScript. If you don’t know the difference - watch this video.

The most popular approach for building frontend with ClojureScript is using React. You can use it via a wrapper library called Reagent and describe UI components as pure functions returning Clojure data structures.

One of the biggest Ukrainian internet-shops Kasta uses ClojureScript with React.

Kasta frontend

Mobile

Mobile development is also possible with Clojure. The stack you can use here is ClojureScript + ReactNative. Though it is not as popular as frontend or backend.

I did a quick search on job boards and didn’t find Clojure mobile positions published now.

But they exist. For example Status company where I met Clojure for the first time and worked for a few years has a mature blockchain-based mobile messenger written in ClojureScript with ReactNative.

Status app

Scripting

Another area where you can use Clojure is scripting. Whatever you write in Bash, you can write in Clojure and without switching your brain context to another syntax.

But If you will write the scripts with JVM Clojure there will be an issue - long startup time.

Instead, you can use a tool called Babashka. It is a native Clojure interpreter that implements a sufficient subset of Clojure and goes with a bunch of prepacked libs to work with the filesystem, command line arguments, json. All these packed in a standalone binary, that you can deploy anywhere and run Clojure without JVM.

On my local machine, I use babashka script that generates folder structure for the new blogpost and new video project when I start preparing them.

Desktop

With desktop development, the situation is more complicated than with all mentioned before. There are different approaches to creating interfaces.

If you decide to use JVM Clojure, you can use one of Java UI kits. Either directly, or via more idiomatic wrapper libraries.

You can use Clojure + JavaFX like the guys from Defold. They wrote an editor for their game engine this way.

Defold game editor

Or you can use Clojure + Swing, like in this tool (beat-link-trigger). Unfortunately, I have no idea what it is for but will leave a link in the description.

You can create web-UI with ClojureScript + React and wrap it in Electron.

One more approach - to write an app in ClojureScript + Microsoft’s version of react-native for windows or macOS.

Or you can try to write an ipad-compatible app with standard React-Native and run it on Mac using apple’s project Catalyst :)

So you can see, there are really a lot of choices but none of them dominates, which means they all have flaws. You can read a good article from Niki Tonsky where Clojure UI problems are discussed. Also to address the problems Niki Tonsky started the development of a new UI for Clojure, called Humble UI. So now we have one more option :)

Ah, and there is also a new version of Clojure in active development - ClojureDart. It is a port of Clojure language to Dart with the primary goal of using Flutter framework and getting a native mobile and desktop UI.

So one more option, yes :)

Embedded

As for embedded, I haven’t heard about production Clojure in this area, sorry.

But here is the video with an experimental running ClojureScript on ESP32 chip.

Conclusion:

As you can see, there are situations when Clojure is not very convenient. But there are plenty of situations where it is. And if you are, for example, fullstack developer who occasionally writes scripts, you can use different flavors of Clojure in all your tasks ;)

Clojure ClojureScript backend frontend mobile desktop