Kool-aid of Clojure
Been looking at Clojure for a little while without actually learning it. Now that I’ve finished a course taught by Martin Ordesky on Functional Programming in Scala, I think I’m ready to tackle (and compare) Clojure.
I’ve already enjoyed gallons of Lisp Kool-aid back in college (and have been a member in good standing at the Church of Emacs for more than twenty years). I consider Lisp’ concepts (and even its syntax) to be better than the languages I use during my day job.
I chuckle how many programmers dismiss Lisp, Scheme and by association, Clojure, because of code like this:
(+ 1 5 3 7)
Everyone knows it is supposed to be:
1 + 5 + 3 + 7
Infix is nice when writing equations on paper, since you need some sort of separator between the digits, but most programmers use prefix notation more than infix. My equation doesn’t look odd if I rewrote it like:
(sum 1 5 3 7)
Note the equivalent code in a C-ancestral language would be:
sum(1, 5, 3, 7)
But the advantage of a Lisp language means that you don’t worry about operator precedence. I know what you’re thinking. Of course, Lisp doesn’t care about precedence since it uses parens around everything.
Guilty as charged, however, the complexity of operator precedence and similar rules in Scala could make baby kittens cry. Colons at the end of a function name, er… operator associates to the right… but only if you separate the text from the colon with an underscore? Nothing wrong with that, but…whew, I remember learning the syntax for Scheme in a single afternoon from the first chapter of SICP.
My point is not to convince to like Lisp-style syntax, but just to admit that it is ok and not that strange.