So I am a raspberrian, too. It’s a fascinating toy and I have a few fun projects (and one serious) in my head that I’d like to do with it - starting with obligatory LED experiments, of course! :) Using RPi isn’t the only thing that will differentiate this endeavour from my previous hacker projects, though. I’ve also decided that I want this project to be 100% JVM-free (yes, that means my-beloved-Clojure-free).

I like JVM. It’s a fast and ubiquitous platform with myriads of possibilities for whatever project you come up with. But that doesn’t mean I need to use it all the time, right? Moreover Java isn’t very performant on RPi, for obvious reasons…

What am I going to use then? Well, the title of this post says it all - almost. Apart from Racket I’m planning to use Riak as a database for some of the projects (see https://github.com/dkvasnicka/racket-riak). But even though I’ve already decided on technologies I wanted to do some performance tests, just out of curiosity.

So I took Racket, Clozure Common Lisp and Clojure and created a primitive program that computes dot product for two lists containing numbers from 0 - 999.999.

As you can see I’ve forced the evaluation of the Clojure sequence, just to make things a bit more fair. Racket’s range function isn’t lazy (and the #lazy dialect does not contain it’s counterpart, AFAIK) and neither is Common Lisp’s for . I know there are other “variables” in this equation. I didn’t consider the types of numbers used (bignums?), I don’t care about the exact types of collections used… yeah, a bit too simple, you might say. But I believe it’s enough for doing just a rough comparison - just to get a glimpse.

My Raspberry Pi is running the latest version of the official Raspbian distribution (which is 2013-05-25 at the time of writing this post). I’ve also removed all the X.Org & desktop packages, icons and all that stuff because I’m not going to use GUI on my RPi. And here are the results of my “wannabe benchmark”:

Clozure CL 1.9 - 6 secs

secs Clojure 1.5.1 running on JDK 8 for ARM Early Access (hard-float support) - 21 secs

secs Racket 5.3.4 - 30 secs

Huh. Something’s not right. 30 seconds? A bit too much, I’d say… At this point I was kind of disappointed. I knew CCL (like SBCL) is a wicked fast Common Lisp implementation and I wasn’t expecting Racket to outperform it. But getting beaten up by Clojure that much?

So I went to the almighty #racket IRC channel and after a quick discussion I’ve found out that JIT support for ARM has been included only recently and that it probably isn’t in any of the official builds. So I cloned the Racket Git repo and - to be sure I have the latest and greatest - built the master HEAD (it takes ages but that’s how we roll on Raspberry).

And guess what! It ran the same program in 12 seconds. Now we’re talking! So if you’re planning to use Racket on Raspberry Pi be sure to grab the source right from the GitHub oven. You have to build it from sources anyway, so just don’t take any of the already-released versions - for now.

And why not Common Lisp, you might ask? I kind of like Scheme and Racket more (not just because of the Lisp-1 vs Lisp-2 dichotomy)… I wrote about it a bit more here (in Czech language). I’d like to do some CL project in the future but now it’s just not the right time for me :)

BTW: I also tried to run the Clojure version with the OpenJDK 7 build that can be found in Raspbian repos. It is a JIT-less JVM, so the situation is similar to the one with Racket. It ran in - wait for it - 224 seconds! :)