Wednesday, September 2, 2009

Since its all the rage to abandon Java lately. Or to become a polyglot programmer.
I did some due diligence on learning new languages, by taking a look at clojure.

There are some pros and cons. Frankly, the cons are much much larger than the pros right now. Overall all, I'd say its promising. But its really the infancy of clojure. Or even a fetal stage.

Some pluses.
Pretty easy to pick up, if you've ever dealt with lisp in the past.
Lightweight. The clojure jar is very small and unobstrusive.
Functional. Yep, its functional.
Concurrent. This is more of a wash. I'm not seeing any advantage here.
The eclipse plugin works. Bare bones, yes. But it works. (Hint, hint Scala team.)

Now some cons. I would view this as constructive feedback more than dinging the language.
Documentation - not good.
closure-contrib - Its a mess. I see some potential for this to turn into the chaos of CPAN. Please head that off now.
Threading/concurrency. Not really that great or easy. Scala and the actor model are better.
Java interop - for claiming to be one of its strengths. Its not good, especially compared to competitors like Scala, Groovy, etc. The way you code against Java APIs just doesn't feel right. Talk about impedance mismatches. This makes OO and RDBMs seem like peanut butter and jelly.

And probably the biggest road block to adoption. Its lisp. Now if you are lisp person already. It might tempt you. And get you on a JVM platform. However, if you're a lisp user now, you probably wouldn't stoop to the level of Java or the JVM.

On the other hand I don't see it drawing too many non-lisp developers.

One other ding against clojure. Its targeting the JVM, Java interop, and I'm assuming Java developers. The pure functional approach is a steep learning curve. The hybrid OO/functional approach of Scala is much more appealing. Its not going cold turkey to drop OO. You can ease into functional or just use some occasional functional techniques like closures.

Also, I have to say. Is OO really that bad? The industry has developed OO concepts for 30+ years. There must be some wisdom there, right? But like anything else, it can be abused and overused.

As an extended side note. If you're considering clojure because its functional, concurrent, etc.

You should consider taking a look at Haskell and Erlang.
Haskell with the STM has a very strong case for solving concurrency issues. Tthe STM is one of the most interesting concepts I've come across in a while for solving concurrency/threading issues. (Yes, I've had my head in the Java sand for a while.)

And Erlang with the actor model is flat out the best technique I've ever seen for threading and concurrency. It feels natural and its dead simple to pick up.

The other huge pluses with Haskell and Erlang. They read much better than lisp. And not just a slightly better, much much better.

One more plug for Erlang. If you believe in a VM for your languages. Erlang has it. Its a battle tested VM. Telcos have using for years. Not just to process data, but to actually run telco switches. And the financial industry is moving to erlang for market trading apps.

More on Erlang later. I've got some Haskell and Prolog to brush up on.

No comments:

Post a Comment