Keep your friends close and your enemies Clojure

Codeidoscope
3 min readAug 1, 2018

--

Three days ago, I started my journey in functional programming. After oohing and aahing for approximately fives minutes, I settled for Clojure over Scala, for no other reason than I had to make a choice between the two and the only requirements I was given was to pick any language on the JV machine other than Java.

Cool, Clojure it is. Armed with an Apple laptop (using High Sierra 10.13.6 at the time of writing) and my trusted Google, I checked to see if it was possible to install Clojure through Homebrew, a package manager that has so far made my life infinitely easier by not having to manually install everything I need to code. There are other package managers (such as Nix and pkgsrc), but Homebrew has worked well for me so far, so I haven’t tried anything else. I’m sure that will change when something in there conflicts with something on my machine and I’ll spend hours trying to debug the issue, but I’ll cross that bridge when I get to it!

How I set up Clojure on my machine

Step one:

Install Homebrew by pasting the path provided on the official website into a Terminal window.

Step two:

Attempt to enter brew install clojure on the command line, before seeing an error message appear stating that you need to install Java first.

Step three:

Install Java via Homebrew so that you can then install Clojure. I used brew cask install java to do just that.

Step four:

Actually install Clojure for real this time. brew install clojure should still work!

Step five:

Remember all the articles you’ve just read that recommended installing a Lenin-thing as well as Clojure? Leiningen (not Leningrad) is a nifty tool to help you make the most of Clojure. It will help you set up projects and includes a REPL for you to use. I haven’t worked out all the good things it does just yet.

You can install it through Homebrew using the brew install leiningen command.

Getting started with Clojure

As I have no experience of functional programming or any JVM language and certainly no experience of Clojure, I have been using a few different resources to help make sense of the syntax and the paradigm shift from OOP to functional.

Books

  • Clojure for the Brave and True — Daniel Higginbotham (Safari link)
  • The Joy of Clojure — Chris Houser and Michael Fogus (Safari link)
  • Living Clojure — Carin Meier (Safari link)
  • Programming Clojure — Aaron Bedra, Stuart Halloway and Alex Miller (Safari link)
  • Getting Clojure — Russ Olsen (Safari link)

Websites

4Clojure — A collection of problems to be solved that will help you get to grips with the syntax

Clojure 1.9 Cheat Sheet — A nifty list of functions associated with the elements that make up Clojure (strings, collections, transducers (?!))

Introduction to Clojure — A guide that covers the basics of Clojure to help you hit the ground running

Getting Started in Clojure — The official documentation to help you learn the language.

Other

The Clojure Style Guide — A guide to stylistic best practices in Clojure

Clojure Koans — In the same style at 4Clojure, this is a list of “koans” — bitesized problems to help you get familiar with Clojure

Clojure Cookbook — A repository for the eponymous book that list common manipulations in Clojure

Clojure API Index — The list of public functions and variables, including descriptions and links to examples.

I’ve been reading a little in order to get the general gist of Clojure, then practicing with koans and 4Clojure. The going is slow, it’s not an easy task to try and forget everything I know about coding and learn a whole new system, but I can already see a little progress. All I need to do is to keep at it!

--

--