

The Case for Clojure - coglethorpe
http://codetojoy.blogspot.com/2009/05/case-for-clojure.html

======
jimbokun
'At NFJS shows, a common question is "I only have time to learn one new
language on the JVM: which should I pick?".

The easy answer is true: it doesn't matter. Just pick one already!'

So what is the 75% answer to "which other JVM language should I learn?"

I figure it's either Clojure or Scala, but not sure which one. I prefer
Clojure and it seems to get a lot of buzz on HN and proggit, but Scala might
be a more straightforward "upgrade" path from Java, and might have more users.

~~~
swannodette
I'd say Clojure. Clojure is very small (Scala seems quite complex).

The concurrency support is fantastic. I've never really had the patience to
understand programming for multiple processors in other languages because of
the complexity of locks. Clojure has lockless concurrency (via STM)- writing
applications which take advantage of multiple processors is trivial!

The following shows easy it is to split work between two cores (if you have
them). This code counts to 250,000,000 but does so on two separate threads. It
takes half the time of performing the operation on a single core.

(def agentA (agent 0)) (def agentB (agent 0))

(defn my-inc2 [v] (loop [x 0 result v] (if (= x 125000000) result (recur (inc
x) (inc result)))))

(defn split-my-inc2 [] (send agentA my-inc2) (send agentB my-inc2) (await
agentA agentB) (+ @agentA @agentB))

