Fast JavaScriptCore Desktop ClojureScript REPL

July 16, 2015

It turns out that JavaScriptCore is very fast when it comes to the bootstrapped ClojureScript runtime. So fast, that I find it remarkable that my humble iOS device can launch the Replete REPL faster than my Mac Pro can launch a Clojure REPL.

Of course, it makes sense to take things to the absurd extreme, and do essentially the same, but with JavaScriptCore running directly on the desktop.

Introducing: Planck.

This is actually fairly easy to pull off, given where we are. In fact—luckily—even though the Objective-C code in Ambly was designed to work with iOS, it can work in an OS X app. (Ambly is used to bootstrap the ClojureScript runtime in Replete, and reusing it in a command-line app is a little odd—I can discover it with Bonjour, connect with WebDAV, etc., but hey!)

One nice consequence of this is that it provides extremely convenient access to a bootstrapped ClojureScript environment targeting JavaScriptCore. For me, this makes it much faster to try things out. Replete is cool when you are on the go, but nothing beats banging on a keyboard into a terminal.

One holy grail is the ability to efficiently script things with Clojure. While ClojureScript compiles down "low-latency" JavaScript, which can be used to cobble together command-line apps, what you really want it to be able to dynamically script things. With bootstrapped ClojureScript, you essentially can.

I added some simple I/O facilities to Planck: slurp and spit, just as a proof of concept to see how things work out. Here is a demo of it all in action:



I really think we are just beginning to scratch the surface of the things that are possible now that we have bootstrapped ClojureScript: I usually think of CloureScript's “reach” as a spatial concept, but perhaps its reach also applies to time as well.

Tags: Planck ClojureScript Bootstrap