Using a REPL to Develop … a REPL

July 22, 2015

Previously, Planck (and Replete), were bypassing the ClojureScript cljs.build.api in order to put together early working bootstrapped ClojureScript environments based on unreleased code from ClojureScript master.




Now that support for bootstrapped ClojureScript is starting to land in master—in the cljs.js namespace—I've started revising Planck to use this namespace instead of having it roll its own homegrown solution. (One nice consequence is that the previous build script, which involved about 60 lines of Clojure, is now a single call to api/build that looks like this

(api/build (api/inputs "src")
  {:output-dir "out"
   :output-to  "out/main.js"})

and where previously in planck.core it would have to explicitly make the appropriate calls to read, analyze, compile, and evaluate, it can use the simpler cljs.js/eval-str that is now in master.

To help sort out kinks in the new cljs.js API, I've been updating Planck now, rather than later, so that it can help serve as a sample client of this new API, putting it through its paces.

Having said that, since cljs.js is still under development, it is evolving, and I'm having Planck track changes closely. And given that Planck is a bootstrapped ClojureScript environment and a little off the beaten path, I fell back into the natural pattern of keeping things as simple as possible:

  1. Build it
  2. Re-run it in Xcode
  3. See that it breaks in some way
  4. Add some println statement
  5. Go to 1.

Ugh. We've all been there before.

But wait! Planck was built by reusing Ambly to bring up the ClojureScript environment in OS X JavaScriptCore. Because of this, it is possible to break this cycle and simply use the Ambly ClojureScript REPL to establish a REPL connection into the Planck REPL for development.

Here is a pic showing it (Xcode on the left, Cursive in the middle, Ambly on the right):




How's that for metacircular? A ClojureScript JVM REPL being used to work on a ClojureScript JS REPL!

Actually, it is not that complicated, but I think it is really cool.

Tags: Planck ClojureScript Bootstrap