Practical Clojure

While the 4Clojure website is great I found myself wanting to do this in an IDE and see some Clojure in the real world (read: not running through a web interface). I did a little research online and found a similar thing on Github - https://github.com/functional-koans/clojure-koans.

The first step to get this working was to install Clojure itself as well as Leiningen. I'm still not sure exactly how to use Leiningen but the installation process for it and Clojure looked like they involved copying some jars and adding some scripts to somewhere on the Path variable. Then I remembered I have Homebrew installed (I haven't owned a mac for long). The installation process then became as simple as:

brew install clojure
brew install leiningen

I then forked the repo and have slowly working through the koans (you can see my progress here). They have been a great learning resource, my only real problem with them is the variation in how much I needed to do to complete each one. Some required a little more than a value, whist others required a couple of lines of code to complete. They were mostly pretty straight forward to complete but I was stuck a couple of times on the larger problems because I wasn't sure if I was doing it wrong and there wasn't a shorter solution.

I would be lying if I said there wasn't a few times that I was stuck due to still not fully understanding the functional way. The tail end recursion problems for large numbers took me a while to understand and I think I will have forgotten it all again in a week. There was also a couple that I embarrassed to say took me way too long to solve, and when I did solve them it was one of those "I can't believe it took me this long" moments.

I still haven't finished the koans but I found myself wondering how TDD and something more practical would work in Clojure. I found a couple of great resources around this. First was this blog which talks about TDD in Clojure using a nice test framework call Midje. I also found a great video which shows a practical example using TDD to build and application - http://vimeo.com/19404746. This video was a really useful for me having recently built a very similar application in Java as an introduction to TDD. It really showed how powerful and concise Clojure is.

Comments