read


read
or learn more

clojure.rb

Jun 9, 2010

Call me crazy, but it seems that there is a large influx of Ruby programmers exploring the Clojure programming language. Based on the results of Chas Emerick’s great State of Clojure – Summer 2010 survey, 17% of surveyed Clojure users come from a Ruby background. Based on observed trends, I expect that percentage to grow in the next round. But why?

An Opening of Minds

Paul Graham’s seminal essays on Lisp were an incredible boon for reawakening the public’s interest in the language. I imagine many programmers, like myself, were awe-struck when reading Beating the Averages for the first time. While I had previous experience with Lisp in a university setting, I was never able to crystalize my feelings on the matter. Upon reading that essay in early 2001 I was driven to an incredible urge to “get me some of that” — which I did by enrolling in an Artificial Intelligence graduate school program in the fall of the same year. I believe, based on personal conversations that there were many who had a similar urge, but chose a different path — the path of “halfway to Lisp”.1 That is, I believe that languages2 like Perl, Python, and Ruby managed to capture a significant portion of programmer mindshare because they not only learned their lessons from Lisp, but they put many of its powerful capabilities in the hands of their programmers.

Enter Clojure

And now years later we see that Clojure, while still humble compared to Java, C++, C, and C#, is gaining increasing popularity and mindshare in the technological zeitgeist. In increasing cases Clojure seems to be gaining serious consideration for, if not outright adoption. But again — why? In my humble opinion it can be summarized as the result of a feedback loop starting with the influence of Lisp on languages like Ruby which again feedback into an increased interest and adoption of Clojure.3

ruby.clj

I would love to hear from Ruby programmers on the following observation4, be it correct or wrong-headed.

The existence of the Lisp feedback loop has lured Ruby programmers in much the same way that Lisp lured them into Ruby in the first place. That is, Ruby programmers being the adventurous lot to begin with, are not satisfied with “halfway to Lisp”. Instead, they want it all. That’s not to say that I think (nor wish) Ruby programmers will abandon ship and run arms-wide to Clojure. Instead, I think that our industry can support both in a complementary relationship modeled (just to name one such scenario) much like the inner workings of FlightCaster. I already see a similar path in Clojure as previously observed in Ruby5. That is, Clojure seems to be used in applications already built on cutting edge technologies (as noted by Chas in his survey results post mentioned in the beginning). Is it really too much to suppose that this environment might also appeal to the Rubyist?

Finally

I’ve babbled on enough about this, but let me end by saying that I fully expect that the inclusion of Clojure into the Well-Grounded Rubyist’s6 arsenal will work to strengthen said Rubyist’s skills and indeed the language itself. Likewise, the presence of Ruby mindshare into the Clojure community will help to motivate a continuing culture of practicality, while also maintaining cutting edge, yet practical, exploration.

Welcome Rubyists7 — it’s a pleasure.

:f


  1. Guy L. Steele in a famous quote mentioned that Java dragged C++ programmers “halfway to Lisp”. While I agree with the sentiment in general, I always felt like Ruby and Python were sitting to the right of the halfway mark, and Java the left. 

  2. I’m not implying that Paul Graham is the reason that these languages succeeded, only that his essays may have helped provoked similar motivations in some. 

  3. That’s not to diminish the herculean effort by Rich Hickey, Clojure’s author, in creating a truly beautiful language that stands on its own merits. But if the industry has taught us anything, it’s that the existence of superior tech does not guarantee adoption. 

  4. Thanks to some compelling conversations with Russ Olsen and Gray Herter at the local Clojure meetups. At times vodka was involved, so I hope I’m not misrepresenting their views on the matter. 

  5. One aspect of the Ruby community that I’ve always been deeply impressed with is the seemingly instant birth of libraries supporting new technologies. Clojure’s community has this to some extent, but it’s nothing akin to the freakish rapidity displayed by Rubyists. 

  6. To borrow a title of fellow Manning author David Black 

  7. And with JRuby we can share the same runtime and libraries. 

22 Comments, Comment or Ping

  1. In a word, yes. As a C/Java guy turned Rubyist/Clojurian myself, I’m not sure it was so much that Ruby got me 1/2 there as it was that in adopting Ruby I rejected about 60% of what I had been taught about software development. No, programming doesn’t have to be hard all the time. No, it doesn’t take 1,000’s of lines of code to do interesting things; No, static typing is not the only thing standing between us and chaos.

    Get past all that and languages like python and Ruby are no-brainers because they are both familiar and liberating. For me it was only when I spend a lot of time with Ruby that I began to realize that perhaps I could take this thing further.

    Russ

  2. I’m not sure that many Rubyists actually were attracted to the language because it was “halfway to Lisp”. When I started out in 2003 what got my attention was “Perl with a nicer syntax and a heavily Smalltalk influenced object model”.

    Judging from my experience as mentor for RubyLearning for the past 16 month, I’d say nowadays by far the biggest attraction to the language is Rails, with “I wanted nicer OO than Java/C++/C#” being a distant second. I can’t remember a single student who mentioned Lisp in an introduction thread.

  3. Michael, thanks for the shout. :-)

    @Russ: I hope you don’t mind if I shamelessly repeat that line: “No, static typing is not the only thing standing between us and chaos.” :-D

  4. Like Michael suggest, I’m also unsure that a major motivator in attracting people to Ruby was it’s ‘halfway to Lisp’ status. I think for most it was due to Rails, although you can probably make a strong case that the reason Rails is so good at what it does is due to Ruby being ‘halfway to Lisp’ (which I think was one of your original points).

    I arrived at Ruby because I fell in love with the beautifully readable and wonderfully lucid syntax. I’m still in love with that aspect of the language. I remember really struggling with the functional parts of Ruby initially, but once I grokked them I never really looked back. In that sense Ruby was for me (and perhaps also for many of the Rubyists we’re seeing in the Clojure community) a real gateway language.

    The tipping point for me was working on some non-web projects. I’m one of the few people that mentioned music as my main usage for Clojure but I originally started off with Ruby. However, after trying (and failing badly) to write well-timed logic, efficient binary device drivers and a concurrent app-switching framework, I realised that I needed more than nice syntax. I needed something that had solid libraries, a better concurrency story and room for optimisation where necessary without having to drop into C. Also, having spent a lot of time exploring Ioke, I knew I wanted something homoiconic with support for macros. Clojure definitely ticks all those boxes.

    Oh, and to be honest, I find the Clojure community’s massively wide set of blog topics wonderfully refreshing after article after article on caching, routing and speccing your controllers…

    I’m very happy to be here, and Fogus, thanks for welcoming me.

  5. One day I heard people call Ruby “MatzLisp” and learned that the design of Ruby was heavily influenced by Lisp, and it was all downhill from there. Many of the things that make Ruby appealing are taken from Lisp. It was a pretty easy choice for me, once Clojure rolled into town.

  6. This is a pretty good description of my own development in Ruby, and it’s why I’ve considered (but not yet seriously used) Clojure.

    Ruby gives a lot of access to powerful LISP-like functional programming constructs and basic metaprogramming without requiring a lot of the inconvenience of full LISP (too many variations, inconsistent standard library support, small/inactive community for a given variant, annoying syntax, and various others). Clojure is tempting because it seems to be getting traction in avoiding those problems in LISP. And hey, real macros. Those would be very, very nice if they could be achieved without the syntactic rigidity.

    Though the syntax still bugs me. Yes, yes, “you stop seeing the parentheses after a few months.” I’ve done that, and no, I don’t. It’s the same problem to me as TYPING IN ALL CAPS. It feels like shouting, even after I’ve looked at a lot of it. Coming from infix languages, parentheses will always mean to me “I’M DOING SOMETHING SQUIRRELY WITH OPERATOR PRECEDENCE, SO EXAMINE THIS CODE CLOSELY AND SUSPICIOUSLY.” Much like the all-caps above, it’s very hard for me not to look.

    And yeah, Paul Graham was why I gave LISP another, more serious look. I was taught it in college, but in an introductory class. So they completely avoided all the actual reasons to use it.

  7. I did not start using Ruby because it was half way to Lisp (at least not consciously). I had a gradual realization that the things I liked most about Ruby were those where it was most like Lisp.

    I remember struggling with the concept of Lisp macros trying to understand why they were so powerful. Once that concept clicked I had a different perspective on metaprogramming, Ruby, and Lisp. Now its hard to see myself going back to a non-Lisp and being happy.

  8. Ruby’s use of quasi-functional features made me interested in seeing more of Clojure. Tim Bray’s posts on Clojure’s performance increased my interest, and Stuart Holloway’s book convinced me to invest some real time.

  9. That is, Ruby programmers being the adventurous lot to begin with, are not satisfied with “halfway to Lisp”. Instead, they want it all.

    Or, some Ruby programmers, being the adventurous lot to begin with, are not satisfied with “halfway to pure functional programming”. Instead, they want it all.

    So I’m picking up Haskell.

    Had I more time I’d love to learn Clojure as well,but in weighing the different FP languages out there Haskell just strikes me as the one that that will do the most to expand my thinking about programming.

    Also, like others have mentioned, I didn’t take to Ruby because of Lisp anything. I liked it for being a solid OO language. It’s pretty clean and sparse (seriously, stop using parens in method defs. It’s clutter).

    And Haskell is even more clean and sparse. As well as a head trip.

    Before making too much of the Rubyists in the Clojure camp, consider what number are moving towards Scala, or Erlang. (Or Haskell even.) And what number of people who, technically, use Ruby but don’t even bother to really learn it and aren’t likely to move to any language until it has enough frameworks and libs and tools and helpers to do the heavy lifting and thinking for them.

    In any event, whatever people choose it’s great that there is at least some interest in these kinds of things.

    Feed your head.

  10. Feed your head.

    I couldn’t have said it any better myself. :f

  11. There is also movement the other ways from people like me, who got interested in Clojure, are told by fellow Clojurian that if we like Clojure, we should like Ruby also, and investigate Ruby 8)

  12. Vincent Murphy

    Responses:

    Brian Carper’s Clojure from a Ruby Perspective http://briancarper.net/blog/clojure-from-a-ruby-perspective

    Hacker News http://news.ycombinator.com/item?id=1417559

  13. Keith

    As others have said, Ruby was a gateway drug for me to functional language concepts rather than LISP per se. Ruby led me to play with Haskell, Erlang, etc., and when Clojure came along, it struck me (after an initial revulsion at the Java aspect…) it was a no-brainer.

    I’m still not sure what the gripe is against parens. Once I “got” the concept of homoiconicity, the parens just made perfect sense to me.

  14. Fogus, your post accurately describes my movement towards Lisp and Clojure specifically. I long knew I wanted to learn and use Lisp; prior to even hearing about Java, Ruby, Python or Clojure.

    Infact I think I first learnt about the magic of Lisp when reading the GNU manifesto in the early 90’s (Lisp is essentially the only programming language mentioned)… After that Paul Graham’s, Beating the averages convinced me it was the holy grail of langauges.

    So it was always an ambition to learn it… And I tried several times, working through some Common Lisp and Scheme tutorials… However because of the library problem and the balkanisation between dialects and implementations I never saw Lisp as a practical language.

    When I discovered Ruby, I’d read a lot about it’s meta-programming and Lisp influence, so I jumped on it, partly because it was cute, applicable to my work and a progression towards Lisp.

    After Ruby I learnt Erlang, as a practical functional language (again a stepping stone towards Lisp and functional languages).

    Finally in 2008 I discovered Clojure, and I found what I consider to be the first practical Lisp… Something worth learning in depth which adopted the immutability aspects I loved about Erlang, Java interop and of course Lisp Macros! Oh and lest I forgot, an incredibly articulate BDFL!

    Anyway thanks for the great post!

    R.

  15. Oh, and one other point… Even though I was never a member of it, part of Lisps appeal for me has always been its community.

    I’ve always been quite fond of missionaries in the technology community who are either out to change the world (e.g. the GNU project) and the cases where the world ignored a revolutionary technology to its peril… e.g. Lisp Machines failing to Unix.

    Though such quests and stories are somewhat Quixotic, they’re as entertaining to me as Miguel de Cervantes Saavedra is to a student of Literature!

    The Lisp communities lamment at its failure to succeed after the AI winter has always struck a chord with me. So many programmers who witnessed the promised land, who knew the future; telling of how we left it behind in the past! It’s moving stuff… and now I’m using Clojure everyday I sympathise with how they must have felt. It’s no wonder Dick Gabriel had to develop a split personality to cope!!! ;-)

    My only hope is that Clojure is the future… It’s certainy in mine, I just hope its in everyone elses!

  16. Michael says it wasn’t “halfway to LISP” that interested him, but “Perl with a nicer syntax and a heavily Smalltalk influenced object model”.

    Ah, but Smalltalk is pretty heavily influenced by Lisp in the first place, so, you might have been interested in “halfway to lisp” without knowing it.

    For me, I’m not sure I was conciously motivated by “halfway to lisp”, but once I was there, working with the psuedo-functional style of programming that ruby blocks get you, combined with working with nice functional javascript in JQuery more… got me re-thinking about my college Lisp experiences more than I had in years, and realizing that I was halfway to lisp, and liking it there.

  17. Kjetil

    Clojure is elegant and powerful, just what attracted me to Ruby, and the JVM is an excellent platform.

    It has really whetted my appetite for functional programming, but now I have mixed feelings about committing 100% to Clojure.

    It sure feels like a step in the right direction, but after seeing the light, I’m eager to go all the way in my quest for language perfection.

    I can’t tell whether Haskell is actually ‘better’, but am sure that learning it will pay off, even if I should ultimately stick with Clojure.

  18. Because the plural of anecdote is data: I got into Ruby because I realized I couldn’t get paid to write Elisp.

  19. mike

    My bacground is classic ALGOL-style languages like Pascal, C, Java and I don’t mind the parens in LISP. Seriously, how can anyone who’s had to earn a living with XML and XSLT complain about S-exps? What’s great about Clojure is: it actually has fewer parens and other soup than ALGOL-like languages like Java and C do (and don’t get me started on the overloading of the asterisk in C++ syntax…)

    I am in the camp that may be prompted to take a look at Ruby after being shown Clojure. Ruby has been on my radar for ages but I kept dismissing it as just another fad, and rails as just php on steroids: not particularly interesting unless you do web stuff. Now I’m going to take another look.

  20. Daniel Werner

    As a former mostly-Python programmer, Clojure has dragged me halfway to Java[1] — something I certainly hadn’t expected.

    [1] Or to the JVM, more precisely.

  21. The talk of clojure being faster than ruby, but as useful, has got me interested…guess I should dive in :)

  22. I’m a Ruby immigrant too. I was drawn to how Ruby kept everything open for extension. While I used that “feature” I later came to recognize monkey patching as something that happens when extensibility is an afterthought.

    I prefer abstractions over concrete implementations and this philosophy was baked into Clojure from the start.

Reply to “clojure.rb”