Finding Clojure
My foray into the Haskell programming language has ended. I didn't quite make it all the way through the O'Reilly Real World Haskell book. Pure Haskell is a beautiful and powerful language. But it's such a pure language that the designers saw fit to segregate pure functional code from code with side effects. The latter is imprisoned in objects called 'monads'. Even something as simple as printing to a terminal is considered a side-effect and so it relegated to a monad.
The proper way to write real world Haskell is to write as much as possible in pure Haskell and wrap the remainder in monad code. But monady code is ugly and unwieldy. It's technically still functional programming, but Haskell has syntax to make it look like imperative programming. I just couldn't stomach it.
So my new interest is Clojure. Clojure is a Lisp dialect that runs on the JVM and has access to Java functions. It's a functional language but not nearly as dogmatic as Haskell.
I'm reading the only Clojure book currently available and finding it an enjoyable language to work with.
As a taste, here's quicksort in Clojure:
(defn qsort [[pivot & xs]]
(when pivot
(let [smaller #(< % pivot)]
(concat (qsort (filter smaller xs))
[pivot]
(qsort (remove smaller xs))))))
Jim on 01.25.10 @ 09:06 AM ET [link]