Clojure is a new functional language for the JVM. This post is a collection of links, articles, screencasts and free books I’ve found to help me learn the language and understand functional program design.
Key features
Here are some key features of Clojure that I find extremely interesting:
- Designed for concurrency
- A Lisp dialect – functional, not mixed-paradigm like Scala
- Compiles to Java bytecode
- Easy interoperability with Java libraries
- Immutable data structures
- Manage state with transactions
A lot of this seems to blow away the languages I use on a regular basis, like Ruby and PHP. Furthermore I’ve had some misgivings lately about the gaggle of run-times I end up using as a multi-language programmer using mostly interpreted languages. So the fact that Clojure compiles to Java bytecode is a real selling point for me, despite my historical avoidance of Java.
An editor
You’ll need an editor to start working with Clojure. Though I’m a Vim user, I could not get VimClojure working right on my machine. Drop me a line if you got it running – hurray for you!
If you are on Windows, I recommend the super-easy-to-install Clojure Box. After a couple of clicks, you’ll have Emacs and a working Clojure REPL. “REPL” stands for Read/Eval/Print/Loop. It’s like IRB for Ruby; an interactive development tool. Emacs makes it easy to pass code into the REPL from an editing buffer, which of course you could do with a bit more elbow grease from Vim using a REPL you spawned on the command line.
Some theory
Now you need to beef up on why Clojure is awesome. The best place is the horse’s mouth: Rich Hickey, the creator of Clojure, has released a number of essays, screencasts and lecture notes describing the benefits of his language.
Screencasts
- Rich’s podcasts on iTunes
- Various screencasts on Channels.com
- A video on concurrency in Clojure
- A video on state and identity
Essays
Syntax
Time to start writing some code! A great place for an overview is the Clojure home page. However, the site can be a little overwhelming or, if you read it a bunch of times, underwhelming. So it is time to branch out and see what the world has to offer.
What we are looking for are introductory examples of Clojure code and more advanced samples of real code.
Blog posts
- Clojure for the Non-Lisp Programmer
- Clojure Programming Cookbook and Clojure Programming
- Building an Ikeda map with Clojure
- Rich Hickey’s code for an Ikeda map
- Cellular automation visualization in Clojure
Not-Free Books
Sometimes, you just need to read a book. Right now, there isn’t much published about Clojure – but I recommend Stuart Halloway’s Programming Clojure.
- Programming Clojure, by Stuart Halloway
- Rich Hickey’s list of books that influenced Clojure
Otherwise, a bunch of books are in “alpha” or pre-release stages from the major book publishers, so the dearth of material should improve by the end of 2010 and early 2011, I assume.
Functional programming
The big elephant in the room! The design of Clojure programs is — or ought to be — different than those written in object-oriented languages like Ruby and Java. I am still wrestling with functional program design, but thanks to the Clojure community and a lot of Googling I have found some sources to help.
Free books
Since Clojure is a Lisp, reading books on Lisp seems like the best approach to learning about the kind of designs that fit naturally into Clojure. Of course, there is also the awesome factor that your programs can interact with Java libraries, which changes things. But if, like me, you have never programmed in a Lisp or any functional language, then — first things first, as the saying goes.
- Practical Common Lisp — hurray, Peter Siebel!
- On Lisp, by Paul Graham
- The Structure and Interpretation of Computer Programs
Blog posts
- Lisp for the Web — a web app in Lisp: awesome!
Community
Really, the best thing would probably be to join the Clojure Google group, and to search the archives for questions you might have. A lot of OO language people seem to wash up on the Clojure beach and they (we) tend to have similar questions.
