Clojure talk
Just got back from an
Object Technology User's Group meeting, where
Stuart Halloway spoke on
Clojure. Whew - not sure I can get any more hyperlinks into that sentence!
Clojure is a
lisp that runs on the JVM. It's full of parentheses, like a good lisp ought to be, and it can be difficult to read for developers who are more familiar with C-derived or
Coffee-based languages. However, like a lisp, the information density in the code is really high, and the amount of idiomatic guarding against edge cases is really low. For instance, you generally don't need to write things like
if (myString != null && myString.length() > 0) {...}
in your code. This is quite refreshing!
However, what struck me as the most important point he made is the observation that good clojure code is about transforming a data structure from what you get into one that's closer to what you need to answer the question or solve the problem. It's about collection transformation, not about recursion. Thinking about 'how could I solve this problem with a recursive function' gets you into a nasty rabbithole and causes you to write the sort of spaghetti code that gives you a bad taste in your mouth from lisp. Thinking about collection transformations, echoing what you do with
MapReduce-style coding, leads you to write code that is more readable and straightforward.
Another interesting point, that I might have issues with, was the observation that "we'll all be writing more functional code in general, and more lisp in particular, in the future." I think the lisp guys have been saying that for the last 30 years,
of which the last 25 or so have been with a lot of bitterness. He might be right, but writing really good, clear, lisp-y code is harder than writing good-enough java. And good-enough java can be easier to sort out than not-quite-good-enough lisp.
Still, I'm more interested in clojure after his talk than I was before it.
And, as a bonus, I won a copy of the
Programming Clojure book! Many thanks to
The Pragmatic Press for donating several copies for OTUG to raffle off.
Labels: java clojure otug pragprog