Clojure Rediscovered
For a long time, I wanted to learn a programming language of the Lisp family. After some investigation, I decided to have a look at Clojure. About four years ago, I bought two books, Clojure in Action and Joy of Clojure. Unfortunately, I didn’t find the time to read them. A few months ago, though, I read The Unicorn Project by Gene Kim. It inspired me to finally take a closer look at Clojure.
I decided to reimplement a simple Spring Boot REST application I wrote in Clojure. The resulting application, called Mock Service, is available here.
For me, this was a revelation. Why isn’t Clojure more popular? (Almost) everything smells good with Clojure. For one, it is compact and requires less code compared to the Spring Boot application. About 100 lines, instead of 700. One file instead of 30. Once I got used to reading Clojure, it was comparatively easier to keep overview than in the Java application.
In Clojure, method definitions are compact, and it feels natural to write them on one line if they are short:
(defn app-status-http [up_down] (if (= up_down :up) status-ok status-service-unavailable))
I am still convinced of object oriented programming, but there are other valid approaches.