I've been seeing articles that say, for instance, "I just learned X programming language 1 day ago, and it's amazing because X Y Z." How can anyone evaluate a language in a single day, or even a week? Programming languages are big, complex organisms that require thought.
I'm writing this article after 3 months of Clojure. Maybe 3 months isn't even enough, but I feel like I'm far enough along to give some basic evaluations.
- The JVM.
This is definitely the best feature of Clojure, the thing that elevates it from Yet Another Lisp Variant to a practical language. You have all of Java's libraries at your fingertips, and Java has more than almost any other language.
Additionally, the JVM puts a low upper bound on how slow your code will be, which is great. It means that, without almost any effort, Clojure is only about 5 times slower than C.
- Hot-swapping code.
Even though Lisp is 50 years old, this still feels like pure magic. You can run a program, send individual functions to be swapped in during runtime, and maintain state while doing so. Iteration cycles drop dramatically. It's gradually gaining adoption in other languages, which is excellent news. (For example, here's a python hot-swapping module.)
- It's a Lisp.
There's never been a language quite as controversial as Lisp. Some people love it for its beauty, and some people derail it for its syntax (those parens!). You've probably formed your own opinions about this one already. Personally, I think that the syntax is pretty elegant, but even after 3 months I find it difficult to read at times. I guess I still haven't reached the promised enlightenment.
- It's (almost) pure functional.
Again, this one's up for you to decide. As my first functional language, I found Clojure code to be - generally - more beautiful than imperative equivalents, but more difficult to write. Even 3 months in, I'm finding that some concepts are very difficult to express in a pure functional way. Again, I'm not sure if this is a lack of understanding, a difficulty in functional programming, and I don't think I'm experienced enough to say either way.
- Error messages.
This is definitely the worst part of Clojure for me - the thing that, in my opinion, makes the language significantly less usable. I've seen things like
NullPointerException at line 0or hundred line long stack traces that never appear to touch my code. The NullPointerExceptions are really nasty, and the only real recourse is to comment out parts of your code. The stack traces are better, but require a lot of obscure knowledge. I hopped on IRC one time to ask about one, and they told me that certain words meant that there was an error in my macro, other things meant the stack had gone through a call of apply, etc.
I'm not sure how you are supposed to pick that kind of information up. Worse, error messages can sometimes interfere with the code hot-swapping cycle and require you to restart in order to fix them.
As to be expected in a language so young, documentation is pretty scrappy.
docin the REPL are invaluable. Outside, clojuredocs is nice, but needs more attention. The definitive clojure reference is solid too, if a bit laconic. Eventually, I turned to just reading the Clojure source, which probably taught me more than the other sites combined.
- The JVM.
It's truly a double edged sword. That startup time is just painful, and to me it means that unless Clojure can run the JVM in the background by default, Clojure will never be a good command line language. Leiningen (the Clojure build tool) is written in the JVM, and on my machine it always takes 5 seconds just to start.
time leinshows about 10 seconds to display all the output, and then it hangs for about a minute more before the process completes. Ouch.
- Set up.
It's quite difficult to go from new machine to machine with Clojure and a good dev environment installed. Both VimClojure and Swank-Clojure for Emacs have rough edges. In the future, I'm planning to write a post about how I do it. Short summary: I'm a Vim guy, but Swank-Clojure is so much better that I would recommend using Emacs with Vim keybindings a la Vimpulse. (I know there's a holy war going on, but really, you've got to use the best tool for the job.)
Is Clojure ready for production? For me, it's not. The error messages are the show stopper for me; I've spent upwards of hours debugging obscure issues. Some of this can be fixed. For example, better stack trace analysis is low hanging fruit. Some of it seems more difficult.
But I don't think that the time learning it was time wasted. Clojure is a clever language, with interesting approaches to old problems (I didn't even get to talk about concurrency, for instance). I'd recommend taking some time to check it out - hopefully more than a week. :)
You should watch this blog (a Github repository) here.