Discovering Clojure

Introduction

Kate Ross-Smith

Discovering Clojure

Discovering Clojure

As Ed Conolly described almost a year ago in this blog post, all of our development teams are full stack. Within this, we as engineers have a range of capabilities, but the microservices we build are written in one of two languages: Clojure and Scala. When I joined the team earlier this year, my eclectic programming history did not involve either of these. So having to choose, I plumped for Clojure. Six months in, I’m loving it. There are various reasons why I thought this was a good choice for me, but I thought I'd see how universal this is. So I’ve asked my colleagues what aspects of the Clojure they most enjoy, and these three came out top.

1. Interactive Development

With Clojure you have a REPL that integrates with your favourite IDE (the most common ones used here are Emacs, Intellij and Visual Studio Code). This allows for development that encompasses a fast feedback loop. If you’re the kind of person who likes seeing the results of intermediate coding steps, the Clojure ecosystem is perfect for this. Also, the Clojure REPL allows you to rebind a function to a namespace, and the good IDE’s allow namespace refresh/ reload. Though it can sometimes get you into a sticky situation where the code in front of you isn’t the one loaded into your REPL (of course, you wouldn’t catch any of us falling for that one. Honest) it is a super tool for exploratory coding.

2. Brackets, Form, Arguments, Bosh

Clojure is a Lisp (which, according to Wikipedia, is the second-oldest high-level programming language still in widespread use today. Fun fact!). What’s cool about Lisps is their spartan simplicity of syntax. Clojure leverages that, adding a little syntactic sugar and porting to the JVM (leveraging its widespread use and well-established reputation). What’s awesome about super simple syntax is that it really frees up headspace to think about the job you’re doing, rather than all of those nitty bits of syntax that you have to get right. Although not a concept that would have appealed to a younger version of me, now I’ll take anything that’s less taxing on the old grey goo.

3. Laziness

I think what first attracted me to development as a career when I was young was realising there was a profession where laziness is considered a virtue. However, this isn’t the “write the minimal amount of code to do the job” laziness. This is the concept where computation is performed when it is needed, rather than ahead of time. Not all of the language is lazy, instead Clojure restricts it just to sequences. This results in some really useful abilities when it comes to list-like manipulation; the ability to have infinite lists without the universe imploding, and the fact that if you want to nest different functions on a sequence, Clojure doesn’t have to compute the interim values.

Further Reading

There are, of course, many more reasons why Clojure is pretty damn cool. A good first port of call is always the official Clojure website, which has some great articles to get you started with the language too. If you've not come across any of the terms I've used here before, head over to Daniel Higginbotham's website Clojure For the Brave and True - it's a fabulous resource for all things Clojure, explained in a really accessible way.

What's Next

As my colleagues agree, there are some really key reasons why Clojure was the language to pick. That said, I’m a big fan of those "What If?" Books. You know the ones that imagine what would happen if some seemingly dramatic historical event happened differently. Which makes me more than a little curious about what life would have been like if I’d chosen Scala instead. So I've been asking the same questions of Ovo's Scala folks as I did our or Clojurians. Come back next month to find out what exactly they think I'm missing out on!