Meditations on programming, startups, and technology
New Relic

Thoughts on Clojure

Lisp has had a tremendous impact on the world of programming. Even though Common Lisp and Scheme — the two main Lisp dialects — may not be considered mainstream today, several popular languages have been influenced by one or both of them.

It isn’t stretching things too much to say that both Ruby and Python can be seen as slower, easier (for beginners), object-oriented, infix Lisp dialects.

Some may say Ruby is a bad rip-off of Lisp or Smalltalk, and I admit that. But it is nicer to ordinary people. — Yukihiro “Matz” Matsumoto

Ruby and Python aren’t intimidating and remain very approachable for absolute beginners. Furthermore, their approachability is not confined to the language design itself, but transcends into the community and ecosystem that surrounds them.

I’m not here to discuss how languages like Ruby and Python managed to become more popular than major Lisp dialects nowadays. I’d rather focus on how these gentler introductions to functional programming are acting as gateway drugs to Lisp for many developers.

A community that values metaprogramming and is obsessed with the construction of DSLs (Domain Specific Languages) like the Ruby’s is, will no doubt find in Lisp a valuable ally. Plus, if you know Ruby inside and out, you should find Lisp to be easy enough to learn.

To attract Ruby developers though, Lisp has to offer something more than just a set of powerful features. You could say that Rails is enough of a reason to learn and use Ruby. But what is Lisp able to solve all that better than Ruby? I’ll answer that question by focusing on a specific dialect of Lisp, that I and continually more Ruby developers are getting into: Clojure.

It wouldn’t be fair to characterize the Lisp community as stagnant, but Clojure is definitely a welcomed dose of new blood. Clojure is a JVM-based modern Lisp designed for concurrency, which elegantly includes a set of carefully chosen features that are not easily found in mainstream languages.

In my opinion, Clojure has three main advantages over Ruby:

  • It’s much faster than Ruby, which makes it a better choice for intensive processing. (FlightCaster for example, uses both Rails and Clojure. Rails for the “front-end” and Clojure for the heavy lifting/forecasting.)
  • It greatly simplifies concurrent programming, making the language more future-proof as hardware manufacturers continue to produce processors with more CPU cores.
  • Clojure emphasizes functional programming and tries to minimize side effects.

Clojure’s interoperability with Java resolves the issue of only having a few available libraries, which often affects new languages. It also helps in getting people to use the language within the enterprise world where Java still dominates.

Of all the “new” languages out there, I find Clojure to be the most fun, interesting and pragmatic: it’s something worth getting excited about. I don’t really care if it turns out to be the next Ruby or not, it’s a language that’s worth knowing and using. (If you haven’t tried it yet, a decent, short introductory book is the recently published Practical Clojure.)

Clojure’s popularity may even bring more attention to Lisp in general (for example, most must-read literature uses Scheme or Common Lisp). Perhaps then, it may indirectly help introduce more traditional Lisp dialects to a new generation of programmers.


If you enjoyed this post, then make sure you subscribe to my Newsletter and/or Feed.

receive my posts by email

5 Responses to “Thoughts on Clojure”

  1. A Hacker News commenter linked to a great comment on how to get started with Clojure: http://news.ycombinator.com/item?id=1033503

  2. John Smith says:

    I also find Clojure to be the most fun, interesting and pragmatic.

    Immutable data structures they actually made it work in log32n.

    lazy / infinite sequences and memoization – a nice powerful way to solve problems.

    Destructuring and sequence comprehension – a wonderful mechanism that lets me clearly express how I want to deal with my data.

    No one notices () after the first 2 weeks. Use an editor that colors them if you like.

    I get more done in a day using Clojure (by far) than I could in a day using any other language over the past 20 years. Any my Clojure code is better designed and has less bugs and performs better given the same effort.

    Rich’s videos on Clojure are a great way to enlighten yourself about a cool new thing in your universe.

  3. Dave says:

    There’s an interesting dissection of the SE Radio interview by Rich Hickey (clojure author) here:

    http://whiley.org/2010/06/23/rich-hickey-on-clojure-se-radio/

    This talks a lot on the advantages of using values and pure functions, compared with the normal OO approach.

  4. [...] Wikibooks as a base, but I built on top of it , so as to customize and improve it.'; My previous post about Clojure generated quite a bit of interest, so I thought I’d follow it up with something a bit more [...]

  5. Sahil says:

    Nice!
    I am definitely going to give it a shot.

  6. roger says:

    So what’s your take on Scala? Not as “fun, interesting, and pragmatic”?
    -r

Leave a Reply

I sincerely welcome and appreciate your comments, whether in agreement or dissenting with my article. However, trolling will not be tolerated. Comments are automatically closed 15 days after the publication of each article.

Current ye@r *

Copyright © 2005-2014 Antonio Cangiano. All rights reserved.