Vibe Clojure 5: WWW REPL
One thing about being written in Rust is that Clojurust can target WebAssembly, as long as it’s not doing anything too advanced. Stripping…
One thing about being written in Rust is that Clojurust can target WebAssembly, as long as it’s not doing anything too advanced. Stripping down the runtime to the bare essentials of the tree-walking interpreter, GC, and standard library should allow us to run Clojurust programs in the browser. So that means we can have a REPL.
I went ahead and implemented this, and put it on the bottom of the project’s homepage: if you type Clojure into the text box on the bottom of the screen and click “eval” (or hit Shift-Enter) it will evaluate your Clojure code in your browser, and “print” the result at the bottom of the web page content.
It’s honestly a little incredible that this is possible. The runtime is surprisingly slim, too, at least for this age of computing: the WASM binary clocks in at almost 3 megabytes, which is tiny compared to most web page assets you come across. And that’s a whole runtime with a useful standard library, and a GC (no, I haven’t measured how well the GC works in the browser; but it is in there and should collect).
I don’t know if this has any useful benefit over ClojureScript for browser development, but it’s pretty neat.
Check it out: https://clj.rs.