Monthly Archives: November 2015

The Mastodon in the room: Why Clojure?

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 (LisProcessor), 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

We’re on the Whitehall steering group of “digital and data visionaries”

It was announced yesterday that Fran, our CEO, will be on the new steering group of “digital and data visionaries” helping the UK government become more and more data-driven. We’re obviously very excited about this – both because it’s an honour to be asked to participate, and because we’re genuinely keen to put data to work in a way that really affects our lives for the better.

The full list of members is:

  • Sir Nigel Shadbolt from the ODI
  • Mustafa Sulyman from Google DeepMind
  • Fran Bennett from Mastodon C
  • Xavier Rolet from the London Stock Exchange
  • Mark Thompson from Judge Business School
  • Dame Fiona Caldicott, former Chair of the National Information Governance Board for Health and Social Care