clojure is the best lisp yet

I've dabbled in a few lisp dialects, but I generally become frustrated with some deficiency or other. I had been holding out some hope for Paul Graham's arc, but when I tried it out, I wasn't exactly blown away.

Common Lisp has a rather bloated library of functions, many with disgustingly long names. Arc has indeed successfully addressed this problem, and so has clojure: the longest function name I could find in Clojure's succinct and powerful library was the outlier "clear-agent-errors".

Lisp is old enough that many dialects have trouble with modern character encodings. Arc doesn't support anything but ASCII (so far anyway), and although elisp does it seems to regard UTF-8 with suspicion. Clojure supports UTF-8 out of the box, even inlined in your source code.

Many lisps have a shocking shortage of useful library modules for common tasks, especially related to networking or particular file formats, when compared to Perl, Python, etc., and creating bindings for existing C or other native libraries can be pretty tricky. Clojure allows you to directly use any part of any existing Java library, no special bindings needed.

With a large variety of libraries comes name collisions. Arc apparently hasn't addressed this problem yet, while clojure has all the namespace support you'll need.

JavaScript and other modern languages have demonstrated to me the power of hashes and the utility of being able to easily initialize them with literals in my code, yet few lisps make this convenient. Clojure has rich support for sorted maps, hash maps, and struct maps (which allow you to efficiently store a large number of hashs with common keys), including succinct syntax for creating new ones.

Besides cleaning up some of lisp's historic weaknesses, clojure provides several innovative new features. For example, the idea of data structure interfaces allows you to write code that can work the same on a variety of concrete types. The (conj ...) function adds an item to a collection, whether that collection is a list, a vector, or a hash.

I also found it interesting that Clojure's built in data structures are all immutable. The API makes working with these convenient, and should allow you to avoid common hassles when dealing with concurrency.

There are many other little details that clojure seems to have tweaked for the better compared to older lisps. The syntax for defining macros is a little tidier, (cond... ) is a bit more succinct, and it even has support for literal regular expressions.

I don't know that many lisps, and none of them very deeply. But for what it's worth, clojure is my favorite.

My feelings exactly. Such combination of elegance and usefulness is rarely seen. To all interested, I recommend reading the boot.clj file containing the core of the language parallel to reading the docs.
While I agree Clojure is a very neat language, I am trying to understand this claim:

"clojure provides several innovative new features. For example, the idea of data structure interfaces allows you to write code that can work the same on a variety of concrete types."

I am not sure that this feature qualifies as innovative. Many languages have had the concept of interfaces for years. For example, here is code to add an object to any collection in Java:

Collection c = getSomeCollection();
Object o = getObj();
Innovative in the context of Lisps. Check out the presentation. The author talks about this.
In Clojure, functions such as "first" and "rest" are virtual, defined on an interface type.
Of course you're right, Justin. It's only "innovative" in the context of core data structures of lisps. Every OO language I've ever heard of provides this kind of polymorphism.

I should have put the interfaces feature with the other items I was contrasting with other lisps.
I've had the same thoughts exactly, until I realized there is Racket and started to use it.

Now I bow before Racket authors. Don't get me wrong, RHickey is excellent hacker & writer (see "Hammock-driven development"), yet the PLT team seem to have vast amounts of experience, scientific background & attitude. They turn their long-standing experience with Lisps into modern, no-nonsense product.
My problem with Clojure is that I'm not a Java programmer. While reading tutorials and documentation it became apparent I'd have to learn Java first or learning Clojure would be an uphill battle.

That seems to be the problem with these languages who's base is another language. I see the same thing a lot with .Net languages. They focus on people from their base language and close out outsiders. These languages will always have a limited growth until they address that.
Post a Comment

<< Home
A community blog by the members of n01se.net

May 2006 / June 2006 / July 2006 / October 2006 / February 2007 / May 2007 / July 2007 / February 2008 / March 2008 / May 2008 /

Powered by Blogger