As promised, I’m going to post some more information about the Clojure TCO project that I’ve been working on with Dan Friedman. For those who missed it, my good friend Eric Holk posted the video from a talk I gave two weeks about it. Just for a little context, I gave this at our informal weekly PL Wonks colloquium series. We keep it pretty light, so there were a number of stops to discuss certain points and quite a few inside jokes.
I apologize to any Clojurers bored by the basics discussed in the video; the IU PL group is primarily made up of Schemers and Haskellers. While they’re no strangers to Lispy languages, few had used or knew much about Clojure.
When the video went up, a number of people asked for slides, so I have made them available here. Also, here’s the video to go with it (via YouTube):
Some notes worth mentioning about the video:
- At about 4:06, I say that there’s a “cross-compiler from Clojure to ClojureScript.” I of course misspoke myself; I meant to say that it compiled Clojure to JavaScript.
- At around 11:30 there’s a fairly long discussion comparing Clojure’s use of “recur” to Scala’s automatic self-recursion tail-call optimization. I say in the video that I’m not sure why it’s not automatic in Clojure. Clojurers from IRC have said that it’s to avoid “magic” in the compiler in which one would write code they thought was tail-recursive, but then blows the stack. This actually leads into a possible loop optimization suggested by a fellow IU compiler hacker, but I’ll write more on that later.
- I mention a couple of IU undergraduate courses by catalog number: C311 is the programming languages course taught by Dan Friedman and P423 is the compilers course originally taught by Kent Dybvig.
- The video says that the trampoline’s flag is a ref, which was true at the time. I have been informed that this is a faux pas, and the current version uses an atom instead. It may come as no surprise that this was a substantial performance improvement.
- The demo portion was cut off primarily because I had technical difficulties (as always happens with live code demos).
There is of course tons and tons to say about the work that Dan and I have done. I’ve been chatting with David Nolen for a few days, including about the possibilities of reusing the CPS transformer for asynchronous client-side scripting code with ClojureScript, as well as adding full call/cc and shift/reset to Clojure.
I’ve also got enough ideas to keep work going on CTCO itself for the foreseeable future (especially with finishing my M.S. next week and starting work at a real job in the next month). So if you’re an interested Clojurer, please take a look at the code on Github, fork it, play with it, add to it, and have fun! Also feel free to ask me questions; I try to be prompt about answering email and often appear on the Clojure IRC as cjfrisz.
I’m a bit busy with classes finishing up and other research deadlines, but I hope to keep writing some updates about the inner workings of CTCO and talk about where I would like to take the project from here. Until then, enjoy!