Clojure – First expieriences

Even though I should learn or sleep right now, I took a look at Clojure. I have already read about it, for example in Kompottkin’s Weisheiten, but I actually didnt know what to use it for so far.

Right now, I am quite satisfied with Common Lisp, and I will stay with it at least until I finally finish my little Game-Project (it is small, it is primitive, but it has >1800 lines, and so it is worth to be finished). Next year, I will have to work with Scheme – w00tage, the first time I will really have to write code somebody else wants to use.

Anyway, the reason for me looking at Clojure is, that I was trying to iplement Pingbacks and Trackbacks for Common Lisp, which both need XML. For example, Pingbacks use XML-RPC as a notifier-mechanism. I wanted to work with Hunchentoot which provides the API I am used to, but I actually couldnt find a working XML-RPC-Implementation running under Hunchentoot. So I decided to begin to create one myself. I noticed that most XML-Libraries are either old and not maintained (and may not work in the near future), or ffi-bindings with a complex, slow API.

On the other hand, Java has a huge Library for handling XML, creating GUIs, handling 2d and 3d graphics, etc. And it is very portable – properties that Common Lisp unfortunately doesnt have (without a lot more work). There is already a Common Lisp Implementation for Java, called ABCL, but the last time i tried it, it was rather slow, and it isnt supported by the most libraries.

Clojure was made especially to run under the JVM. So it is optimized for that. And it has some interesting innovations. Well, it uses [ and ] – I dont really like this (it is not „lispy“) but I can get used to it. You can access Java-Methods from it – and can create beautiful GUIs using Swing – as this example shows. This is fascinating – a Lisp that can produce real User Interfaces without having to do a lot of strange work. It has no tail call optimization – I actually dont understand this, because you should be able to implement this using Jump-Instructions, but well, it has a special function named „recur“.
The most interesting part so far are the Multimethods. As far as I understand them by now, instead of dispatching according to classes, you can give a function returning a type for every object yourself, and you can define the hierarchy of these types by a few simple – understandable – commands. This actually maps most of the functionality of the CLOS I have ever used.

It looks like this Lisp Dialect has a lot of new interesting concepts. If only I had a little more time to explore it…

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: