Today was my first day playing with Clojure. I have heard snippets about it from so many different sources, most recently in a talk at makers from Fred George.
For an incredibly succinct and accessible demonstration of clojure try Clojure. I was directed to this website and had to run through it. I was hooked immediately. The thing that most blew me away, in five minutes of clojure, was how it treated fractions. It remembers fractions not nasty inaccurate decimals.
user=> (/ 9 4)
user=> (type (/ 9 4))
So the sample above shows that this memory is Ratio type. It also quite clearly shows how far this is from ruby and python. The odd structure “(/ 9 4)” is division in polish prefix notation.
Getting clojure installed on my machine was the easiest thing ever. The recommended method is to install using Leiningen which is a ’build automation and dependency management tool’ for clojure. As Leiningen is already available in the apt core libraries installing it was simply to run the following command
sudo apt-get install leiningen
I can now run the Clojure REPL (read-eval-print-loop) which is the interactive environment. This is started with the command ‘clojure’. Exiting is more tricky and is using.
Or to crash out CTRL + D
So I am sure I will be writing more about clojure here, hopefully not too soon as it will mean I have been distracted from the important business of my final project.
I have just started 4clojure to learn the language