The Mastodon In The Room: Why Clojure?

Seb Bailey
Mastodon C
Published in
4 min readJul 19, 2018

Mastodon C advertises itself as a ‘Clojure shop’ when talking to clients and partners, but let’s delve a bit deeper into what this means and why we believe it’s a key advantage for us. Ultimately, it comes down to a simple idea:

“Simplicity is hard work. But, there’s a huge payoff. The person who has a genuinely simpler system — a system made out of genuinely simple parts, is going to be able to affect the greatest change with the least work. He’s going to kick your ass. He’s gonna spend more time simplifying things up front and in the long haul he’s gonna wipe the plate with you because he’ll have that ability to change things when you’re struggling to push elephants mastodons around.” — Rich Hickey, Creator of the Clojure programming language (edited for effect)

Clo-what?

Clojure is a computer programming language that promotes simplicity, whilst simultaneously being incredibly powerful and broad. It hails from a family of languages known as LISPs (List Processor), which are famous for their distinctive, fully parenthesized Polish prefix notation. It looks a bit like this…

(require ‘[clojure.string :as string])
(defn say-hello [name]
(->> name
(string/capitalize)
(println “Hello”)))
#=> (say-name “archibald”)
“Hello Archibald”

If you’ve ever seen code from other languages, such as JavaScript or Python, you’ll notice immediately that this is aesthetically very different. However, like any programming languages, once you’ve learnt the nuances and the idioms, writing code that is concise yet expressive becomes quite straight-forward. Clojure is especially geared toward a style of programming known as declarative, whereby a programmer, rather than solve problems imperatively (“do this, then this”) is more descriptive (“change this data to look like this”), allowing the underlying language and/platform (the JVM in Clojure’s case) to do the heavy-lifting. The result is often much less actual code — and the less code there is, the less there is to go wrong!

Clojure is predominantly used as a ‘server’ language which means that it’s usually the workhorse at the bottom of a technology stack, doing all of the business logic, logging, management and logistics. This suits us quite nicely, as this is where most of the Mastodon C magic tends to happen — reading in data, crunching lots of numbers, managing distributed computations across the cloud. Having all of our solutions written in Clojure means that we significantly reduce the effect of “silo-ing” people into specific projects. One person can easily move between jobs and this is something we actually mandate as part of our support process.

Pretty things

Recently there has been a big movement to bring Clojure to more platforms. Where once it was almost exclusively big, beefy servers, Clojure is now also available in your browser via ClojureScript — a near-perfect reproduction of the Clojure language which transpiles to JavaScript. This opens up a vast amount of opportunities for development across browser, mobile and desktop, as well as allowing seamless integration with lots of powerful and popular JavaScript libraries — such as React, jQuery, D3 and many more. It’s completely possibly now to write entire client-side web applications using ClojureScript — and many have.

Considering Mastodon C is already bursting with experienced Clojure developers, using ClojureScript for our frontend work is a total no-brainer, and of course comes with the added benefit that — once again — no one is left-behind when it comes to rolling up their sleeves and contributing to the code. There is no “server team” and “frontend team” as is so typical at most polyglot organisations — everyone does everything.

Once more, with feeling

It’s important to note that although our preference lies firmly in Clojure and ClojureScript, we aren’t scared of cutting our teeth on other languages, especially if they are designed for and excel at a specific task — R is a good example of this. However, the benefits of working in a predominantly Clojure organisation are paying dividends for us:

Further reading/listening

This blogpost was originally published on Mastodon C on Nov 5th 2015 by Antony Woods

--

--

Seb Bailey
Mastodon C

Data scientist, baker and retro video gamer, blogging about any of these things.