Is Clojure the only language you need?
Tags: clojure, clojurescript, backend, frontend
Published: 2022-10-12 19:01:17


## Video version
{% embed https://youtu.be/oguZnsrUQBo %}

## The question

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


![Clojure implementations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9lxgogubfblysqy49zg.png)


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](https://en.wikipedia.org/wiki/Clojure#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](https://nubank.com.br/). It is a Latin American digital bank that used Clojure so heavily, that in 2020 they decided to [acquire](https://building.nubank.com.br/nubank-acquires-cognitect-press-release/) 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](https://clojurescript.org/). If you don’t know the difference - [watch this video](https://youtu.be/ABQk9iMUypY).

The most popular approach for building frontend with ClojureScript is using [React](https://reactjs.org/). You can use it via a wrapper library called [Reagent](https://github.com/reagent-project/reagent) and describe UI components as pure functions returning Clojure data structures.

One of the biggest Ukrainian internet-shops [Kasta](https://kasta.ua/) uses ClojureScript with React.

![Kasta frontend](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3gwtudbnk23m1n8nydto.png)


## Mobile

Mobile development is also possible with Clojure. The stack you can use here is ClojureScript + [ReactNative](https://reactnative.dev/). 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](https://status.im/) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0gsn3cghhu0xbvonfi6.png)


### 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](https://github.com/babashka/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](https://defold.com/). They wrote an editor for their game engine this way.


![Defold game editor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ho3yykim55dxcsv6lsb.jpeg)


Or you can use Clojure + Swing, like in [this tool](https://github.com/Deep-Symmetry/beat-link-trigger#beat-link-trigger) (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](https://microsoft.github.io/react-native-windows/) 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](https://tonsky.me/blog/clojure-ui/) 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](https://github.com/HumbleUI/HumbleUI). So now we have one more option :)

Ah, and there is also a new version of Clojure in active development - [ClojureDart](https://github.com/Tensegritics/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](https://www.youtube.com/watch?v=u1jr4v7dhoo) 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 ;)

originally posted at [kozieiev.com](https://kozieiev.com/blog/is-clojure-the-only-language-you-need/)