anmonteiro Code ramblings

The fastest Clojure REPL in the world

One common complaint of Clojure REPLs is their startup time. Although that complaint is often somewhat unfounded (and related to tooling), it still takes the bare Clojure JAR about 1 second to start on new hardware. Planck — through bootstrapped ClojureScript, and owing to the small latency exhibited by JavaScript VMs — managed to improve the time that it takes to bootstrap a Clojure(Script) REPL. A new kid on the block promises to perform even faster. Read on!

Motivation

Not long ago, Craig Andera mentioned on Twitter that he had succeeded in compiling a ClojureScript application to a standalone native executable, using a tool called Nexe:

Being a big fan of Mike Fikes’s Planck, its instant startup and scripting capabilities, I was intrigued to validate the idea that we could have something similar for the Node.js platform. Whether we like it or not, Node.js’s NPM is the largest and fastest growing package ecosystem today. Seamless interoperability with NPM plays a huge part in extending ClojureScript’s reach even further. And as it turns out, this is possible today.

Introducing Lumo

Lumo is a fast, standalone ClojureScript REPL that runs on Node.js and V8. Thanks to V8’s custom startup snapshots, Lumo starts up instantaneously, making it the fastest Clojure REPL in existence 1. Here’s a rundown comparison of Clojure, Planck and Lumo’s startup times.

Lumo employs some tricks to be extremely fast. Some of these (caching, lazy analysis cache loading and AOT-compiled macros) were directly inspired by Planck. Others, such as the V8 startup snapshot feature that is not present in JavaScriptCore, will be the focus of subsequent posts in this blog.

Oh, and did I mention Lumo is cross-platform? Here’s a screenshot of it happily running on Windows:

Peeking into the future

Lumo is not complete by any means. The initial release has a substantial set of features (while we work on setting up a documentation website, you can get a notion of these by running lumo -h or lumo --help), but many more are expected to arrive in the near future. Among these are ergonomic additions such as cursor hopping, pretty printing and colored output, as well as idiomatic ClojureScript wrappers for Node’s APIs, such as performing I/O calls, spawning child processes and more.

Wrapping up

Lumo is free and open source. I think it can serve numerous purposes, many of which I’m unable to predict. I also think that’s a good thing. If you want to try it out, there are standalone binaries for Mac, Windows and Linux here. Be sure to let me know what you think! I’m @anmonteiro90 on Twitter.

I’m curious to learn how you will use Lumo. Thanks for reading!


1 or rather, the one with fastest startup. Lumo runs bootstrapped ClojureScript, and compiling ClojureScript in JavaScript is generally slower than compiling ClojureScript on the JVM. ↩


Thanks to Mike Fikes for reading a draft of this post.