Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Volodymyr Kozieiev
Volodymyr Kozieiev

Posted on • Originally published atkozieiev.com

     

Is Clojure the only language you need?

Video version

The question

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

Clojure implementations

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 ofother implementations.

If you can run Clojure where Java or JavaScript runs, can you learn Clojure and conveniently use it inALL 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 aNubank. It is a Latin American digital bank that used Clojure so heavily, that in 2020 they decided toacquire 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, particularlyClojureScript. If you don’t know the difference -watch this video.

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

One of the biggest Ukrainian internet-shopsKasta 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 exampleStatus 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 calledBabashka. It is anative 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 fromDefold. They wrote an editor for their game engine this way.

Defold game editor

Or you can use Clojure + Swing, like inthis 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 goodarticle 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, calledHumble 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.

Buthere 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 ;)

originally posted atkozieiev.com

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
mebble profile image
Neil Syiemlieh
I like building small tools on the side.
  • Email
  • Location
    Shillong
  • Education
    Indian Institute of Information Technology Allahabad
  • Work
    Currently unemployed
  • Joined

As someone just getting into clojure, this was helpful

CollapseExpand
 
kozieiev profile image
Volodymyr Kozieiev
Write software for 15+ years... still like it 😎
  • Location
    Ukraine
  • Joined

Glad to hear this! :)

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Write software for 15+ years... still like it 😎
  • Location
    Ukraine
  • Joined

More fromVolodymyr Kozieiev

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp