2009-05-15

Clojure

Lastnight I went to the St Louis JUG and Mark Volkmann presented Clojure.   I've heard about Clojure previously, such as on The Java Posse, but I never bothered looking it up and seeing what it was all about.

The presentation was well given and sparked some of my interest into investigating further.  I used to use Emacs all the time and knew enough lisp to get by.  Clojure appears to be a big contender in the functional language race on the Java platform.

The syntax is very simple and has a lot of common ideas that lisp has, such as immutability, working with lists, creating functions, etc.   The part of the presentation that stood out to me is the discussions on Software Transactional Memory (STM).   To me, it's a crazy concept to start a transaction in your code in a way where your "commits" are modifications to references.

Mark gave a good comparison of Scala and Clojure.   Scala was created as a mashup of functional programming and object oriented programming.  The problem, however, is that some of the "cons" of object oriented programming come in, such as objects being mutable.   This causes problems when dealing with concurrency and forces the developer to deal with those issues during development.   Clojure on the other hand forces immutability.  For the places that require mutating a reference, it must be put into a transaction, otherwise it will throw an exception and you'll be alerted early in development that you made a mistake.

I think I'm going to continue looking at Clojure and try a couple of "Pet Store" type projects in it and see how I can incorporate this language in my toolbelt.

No comments: