Skip to content
Tech News
← Back to articles

My thoughts after using Clojure for about a month

read original get Clojure Programming Book → more articles
Why This Matters

This article highlights the practical benefits of using Clojure, emphasizing its cohesive design and simplicity in handling collections and equality, which can enhance productivity and code clarity for developers. Its ergonomic features make it a compelling choice for those exploring functional programming and language versatility in the tech industry.

Key Takeaways

I am now generating this website with Clojure (yes, right after rewriting it in GNU Make and shell; I have a problem, ok?). In a personal tradition, I used writing a static site generator as the project to play with and learn Clojure as a new language. While I’ve long scoffed at Clojure for its copious syntax (three types of brackets!?), it turns out to be pretty ergonomic and powerful. Here are my impressions after playing around with Clojure for about a month.

Things I like

More cohesive than Common Lisp

Common Lisp is so called because it’s a compromise among roughly all the extant lisps when it was written in the early 80s. As such, it’s a weird mashup of programming paradigms and name schemes. Instead of map -ing a function over a list, for example, you mapcar it. Instead of filter , you write remove-if-not , with all the confusion of a double-negative. Overall, Common Lisp has a strong feeling of being designed by committee, whch makes sense, because it was.

Because Clojure is newer and the brainchild of one person, it’s more cohesive as a language. The seq abstraction, for example, means I usually don’t have to worry about what kind of sequence I’m dealing with. Instead of having to remember aref for arrays and nth for lists, I just use nth for everything. It also makes mapping easier: instead of having to remember

;; This is real syntax! (loop for k being the hash-keys using (hash-value v) of hash-table ...) ;; OK, you could also use (maphash (lambda (k v) ...) hash-table)

I can simply call (map (fn [[k v] ...]) hash-table) and be done with it. And remember, map works with any collection.

It’s the same with equality: instead of having to remember the fine distinctions between eq , eql , equal , equalp , and more that are type-specific, I can just call = (or == if comparing numerical values, or identical? to see if values are identical). To be fair, there are caveats, but I haven’t run into them in a month. I had to learn the different equality forms immediately to get going with Lisp.

More “batteries included” than Scheme

Scheme was also built by committee, but you could argue it’s even more cohesive than Clojure. However, it’s “cohesive” in the way that a bicycle is cohesive: it includes very little in the way of ergonomics, paring down the language to its barest bones. Indeed, the introduction to every revision of the Scheme Report begins:

... continue reading