Custom Search

Saturday, December 26, 2009

First reflections on Clojure

I'm always looking for new programming languages - they are, after all, the tools of my trade. So new languages that might make me more productive, or give me a new insight into programming are always of interest. The latest language to catch my attention is Clojure (

Clojure has been described as "LISP reloaded". To me, it's just a modern LISP. It's got some syntax quirks that separate it from other LISPs, but nothing really major is different about it as a language.

One thing that is different is the attitude of the community - in particular the author. Rather than wanting everything to be LISP, Rich Hickey is quite happy to leverage the work of other languages to make things easy his users - and for him. It runs on top of the Java Virtual Machine, meaning he doesn't have to invent and then implement a VM just for his system. It also solves one of the major problems that drove me from LISP earlier, in that Clojure, unlike earlier LISPs - "plays well with others." As a Clojure programmer, I can use Java libraries, which means I can access most system facilities that other LISPs could only get to with difficulty. I can write Clojure code and let it be used inside Java applications. I can even share data with the rest of the system as well as Java ever does.

Of course, just being a LISP with it's major problems fixed isn't really enough to cause me to learn a language. Clojure was designed from the ground up to work well in concurrent environments, which are becoming the way to leverage power in the current desktop environment. So all the native types and most of the native structures are immutable. This means most of your programming is going to take on a functional style, which makes using LISP - the parent of all the functional programming language - a natural choice. The mutable data structures are there to help with concurrency, and allow mutation under different conditions, usually using high-level mechanisms that don't have the problems associated with the usual locks. Locks are even available if that turns out to be the right answer.

As a final draw, people have demonstrated that you can use Clojure to create Android applications, which is something else I've wanted to get into.

So, I've been through some tutorials, read the book, and installed Clojure a couple of times. I've picked a couple of likely projects, and even identified the Java libraries I'll need for them so I can work on the interesting part of the projects, and not have to deal with either hardware details that are largely irrelevant, or writing something for the dozenth time.

So far, I'm impressed. There are a few warts, but mostly the parts fit together well. It's got all the features that drew me to LISP long ago, and the Java integration seems like it's going to deal with all the problems that drove me away from LISP. And the concurrency tools will, if nothing else, provide new insights into concurrent programming.

1 comment:

  1. That's a nice roundup of the language and community.
    Just out of curiosity, what are the various warts you have encountered?