Wednesday, February 17, 2010

Comparing Clojure and Scala as 'Java replacements'

I have been doing more Java coding than I would like lately <grin>. An antidote has been some work with Clojure and Scala. Unfortunately, I have not reached a sufficient level of proficiency with either language that I can instantly switch between them: it takes me more than a few minutes to to get into the flow with either of them.

For customer work, I don't expect either language to be in much demand but since I also work on my own projects I would like to have a good alternative language when Ruby or Lisp (either Common Lisp or Scheme) don't work for me because of lack of libraries or other constraints. (BTW, in the last 3 years, probably 60% of my paid for consulting work has used Ruby, about 30% Common Lisp, and only about 10% Java.)

For my personal development needs, Clojure's and Scala's good support for concurrency is not too large of an issue. What is an issue for me is that I want to be able to use existing Java libraries and frameworks and I like concise programming languages (otherwise, I would simply keep using Java as my Ruby alternative). JRuby is also a powerful contender except that I find that using alternative languages stretches the mind and is worth the small amount of wasted time transitioning from using one programming language to another. I spend so much time using Ruby because it is a required language for projects that I would prefer another choice, even though Ruby is a great (or at least fun) language.

Except for the Common Lisp edition of the AllegroGraph book I am writing, I don't expect to be using Lisp very much in the next few years (unless a customer asks for it), so I would eventually like to settle on using either Scala or Clojure as my "concise Java alternative," but I am in no hurry to make a choice.

I definitely have an easier time integrating existing Java code with Clojure than I do with Scala. That said, I like Scala's syntax better (strange, given the fact that I have been coding in Lisp for over 30 years).

1 comment:

Andrew Whaley said...

Interesting Mark - I would have put money on you preferring Clojure ! I've been getting into Haskell recently and I do prefer the infix syntax as it is often more concise than the prefix alternative. Having said that, I think Clojure has more Haskell features e.g. immutability, laziness and support for monads so it would make more sense for me. Scala seems much more like a traditional imperative language to me with a few functional sweeteners thrown in.