The majority of my time as a professional software developer is spent programming in JavaScript (more specifically, Node.js) and C# (again, more specifically - .NET MVC). When I'm not knee-deep in this mixture, I like to venture into the world of functional programming. And perhaps to discover something new, something completely out of the ordinary. For me, that was Clojure.
My initial investigations into Clojure left me sort of, stumped. The difference even in semantics alone is enough to completely put you off investing your precious spare time into attempting to understand it! What on earth is reverse polish notation? And why is literally everything wrapped in parentheses? Hopefully, this article will help demystify this obscure yet purely elegant language.
As I previously mentioned, almost everything in Clojure will seem downright bewildering to the majority of software developers. With its Lisp-uresque dialect, it truly allows for a more expressive experience, which, with enough time to master, will provide joy to the majority of programmers who are truly passionate about the quality of their code.
To start off, everything in Clojure is evaluated in a uniform structure (or rather, as Forms). That is, it recognises expressions in both literal (i.e defining a map or a vector) and operational formats. For example:
A few things to observe:
Of course, the examples above do not give the language justice in any sense; Clojure has a large variety of native simple types and intuitive data structures.
This is all great and fine for a REPL, but what about actual programs? What do we do when we have a particular piece of functionality in mind? Functions that's what!
In the operational examples above I also forgot to mention one thing: and that was the calling of the native Clojure function; first. Clojure has a large number of native functions, but what about defining our own functions? Here's a good basic example of defining functions:
As the comments in the example above state, we're seeing a very simple function being defined, passed parameters, and then returning a result. You can also declare anonymous functions (much like JavaScript for example), using the following notation: “(fn [params] body)” (so just swap defn for fn). Functions in Clojure are also similar to javascript, in that they can, in fact, return other functions and be passed functions as parameters (first-class functions).
Clojure as a language provides a unique way to write complex applications. It provides an elegant, powerful syntax which makes complex applications seem trivial to write. There is a LOT more that can be said about Clojure, but to get started in writing Clojure head to Try Clojure to start a REPL, and writing awesome stuff! If you're like me and like to get straight into reading about Clojure, I'd highly recommend Clojure for the brave and true (http://www.braveclojure.com/); a fantastic read to really get to grips (and it's also free to read online).
WRITTEN BY JOE NORMAN
We are a leading niche digital & tech recruitment specialist for the North East of England. We Specialise in the acquisition of high-performing technology talent across a variety of IT sectors including Digital & Technology Software Development.
Our ultimate goal is to make a positive impact on every client and candidate we serve - from the initial call and introduction, right up to the final delivery, we want our clients and candidates to feel they have had a beneficial and productive experience.
If you’re looking to start your journey in sourcing talent or find your dream job, you’ll need a passionate, motivated team of experts to guide you. Check out our Jobs page for open vacancies. If interested, contact us or call 0191 620 0123 for a quick chat with our team.
Follow us on our blog, Facebook, LinkedIn, Twitter or Instagram to follow industry news, events, success stories and new blogs releases.
Back to Blog