Getting some Clojure

I’ve been learning in Amsterdam, so to speak.

It all came about when I decided I was going to learn a new programming language as a Summer project, and as usual turned out to be a little more complex than that.

The Amsterdam bit is easy enough to explain – I’ve been using my DigitalOcean VPS for a few months now as a sort of “home away from home”, which allows me to use remotely1 from my and get a surprising amount of stuff done without having to cart a full blown laptop around.

The bit, well… not so much, hence the rest of this post.

Why ?

Even though still gives me the most bang for the buck (both in terms of productivity as well as performance, provided you know what you’re doing), most of the hard stuff I’m tackling these days falls into two broad categories:

  • Moderate to heavy concurrency across multiple machines
  • High-volume data processing (in either throughput or size)

I’ve been able to tackle both reasonably well with by tapping into PyPy or gevent for a little extra speed, but even though I love the standard library and ecosystem, I was not too happy with the abstractions readily at hand or the amount of hoops I was going through to tackle a few specific problems, so I decided to explore alternatives.

I started out by looking at again, then at the Actor model in Pykka, then at Akka (at which point I branched out into Scala, , etc.) and eventually came to the conclusion that all the low-hanging fruit didn’t require so much of a paradigm change as a mindset change in the way I was doing things.

also scratched a few particular itches that had been bothering me of late:

  • It runs on the JVM, and although I hate the quasi-religion has become (in terms of language and IDE dogmas), the ecosystem is huge, the performance is (by and large) excellent, and we do a fair amount of unconventional that I’d like to be able to leverage somehow.
  • Being a LISP dialect, it is both familiar enough2 to be easy to read and highly appealing to my sense of aesthetics
  • It has a clean, unfettered approach at single-system concurrency (and these days anything that doesn’t tackle concurrency well is a non-starter for me), and a number of open-source options for orchestrating tasks across machines.

But what clinched it was the community. The more I read about (and about what people were doing with it) the more appealing I found it to be, largely because the average level of discourse was way above what I’m used to getting in, say, the or blogs I follow.

So I started working through the Clojure Koans piecemeal and doing a few mini-projects3 that made me aware of a few interesting wrinkles:

  • Using on a has become awkward, and is sure to become a massive pain as we move towards Mavericks (plus I really don’t like running Oracle software on my machine).
  • spoiled me somewhat in terms of libraries. Its “batteries included” approach is a severe contrast with ’s relative sparseness and reliance on the ecosystem (I fully expect a couple of dependency management nightmares in the near future).
  • The language core is stable, but bits around it are evolving fairly quickly (core.async being a case in point).
  • There are more back-ends under active development than you’d expect - including, of course, , and even clojure-py, which is somewhat stale but that I managed to get running under Pythonista on the .

I’m not (at all) sold on , though - the intermediate compilation step makes it feel clunky and inelegant, and I wish someone would rip out all the bits and just plug it directly atop V8 somehow. Maybe someone will eventually tackle that.

Why Not , , Haskell, etc?

is still a trifle too unstable (and unfinished) as far as I’m concerned. I’m already familiar with it and even tried Revel, but I’d rather wait until it matures somewhat.

I have no significant trouble coding in it (except for some syntactic aberrations), but it just isn’t inspiring enough – it’s a low-abstraction language that feels like a step back in terms of how to tackle unsolved problems, whereas makes it easy to abstract away computing and cast problems as logic – quite often tackling things in different ways.

So will likely become my “new C”, if you will.

is something I’m , but that I never took to. I loathe the cumbersome syntax, but above all the arcaneness of the whole thing. Elixir is, by comparison, a lot more interesting, but I haven’t come across any problems that seem to be easier to solve with it – at least not if I want those solutions to be maintained by others.

Haskell has always felt completely alien to me, and even though I suspect I’ll eventually end up taking a longer look, it’s just too far off the beaten track right now.

In the end, the choice boils down to which one had the most potential to teach me a new way of thinking with the least pain – and in that regard, wins hands down so far.

The REPL Siren Call

There are quite a few parallels with what I went through a few years back when learning .

I started out learning at an interpreter prompt (and to this day have one permanently open everywhere I work), and am getting to grips with in mostly the same way, alternating between ’s REPL plugin and Light Table.

Light Table is brilliant but rather unstable at the moment4, so I only use it occasionally – but it does have the nice bonus of supporting live and evaluation, which makes it a perfectly natural fit for my usual workflow.

All things considered, though, and given that I spent most of my time using IPython over the past couple of weeks to run test cases and plot charts, I can’t help but wonder what a version of IPython could be like.

IDE-wise, I’ve also played around with Nightcode a bit, and it shows promise – largely because it’s relatively simple and focused when compared to traditional IDEs, which I mostly abhor.

There’s plently more to be said about , but I won’t bore you with it – as usual, I’ve been amassing and there is plenty more out there, so I encourage you to take a look for yourself.

Personally, and considering I’m devoting a fairly small percentage of time to getting to grips with it, I expect to have something interesting to show for my efforts in six months or so, and only become truly proficient in about a year (again, mostly like it was with ).

Who knows, maybe next year I’ll even have the time to have a go at the Clojure Cup.

  1. This setup works wonderfully for me in Jump Desktop - I’ve been using the beta versions ever since they included private key support (now shipping) and a fair amount of keyboard and speed tweaks, so it’s as good as having a “full” computer provided you have a low-latency mobile connection. ↩︎

  2. Ironically, one of the first things I ever used on a Mac was Common LISP back when I started college and it was one of the supporting languages for my AI courses, so “going back” to it is somewhat fitting. ↩︎

  3. One of which was a small benchmark we ran internally, and where knocked most everything else out of the park (including ↩︎

  4. Especially when coupled with OpenJDK 7 in 13.04 – I’ve since simultaneously upgraded to the latest alpha and downgraded to OpenJDK 6, and things seem much more reliable. ↩︎