Running applications should allow stateful interaction using arbitrary code. Loaded code should be hot-swappable. Everywhere. Because restarting is painful, slow and unproductive. The idea is not new. No, JRebel, Spring-Loaded and the like are not the answer, they are painkillers.

Runtimes and languages such BEAM/Erlang or various flavors of Lisp have had excellent support for this kind of interaction for ages. It’s a shame we see it so rarely in „modern“ environments (such as JVM or Node based ones) today. Sure, there are various interactive consoles, terminals or whatever you call them, but most experiences leave a lot to be desired.

REPLs in Clojure / ClojureScript

Now enter Lisp in general and Clojure in particular. Their interaction experience is unparalleled. Tooling and even a lot of application code is designed(!) with fine grained interaction and hot-swappability in mind. Various REPLs executing code in the browser have been around for a while. Still, Clojure REPLs are heavily exploring new ground. iOS JavaScript and Microsoft Excel ? are among recent examples.

I did not go very deep with the JavaScript based execution environments. The Non-JVM based ones such as Node.js require some JVM help due to the fact that macros are (usually) implemented in Clojure. Nashorn seems to be overtaking Rhino quickly in JVM-land, and Avatar.js‘ motivation (allowing Node.js module execution on Nashorn) was promising. Unfortunately, the Avatar.js project seems dormant nowadays.

Don’t know much about Clojure on .NET, but I’m sure they have a REPL. :)

A REPL for your Webapp

I want a decent, secure REPL in webapps. Even in production. So without further ado, the following video might give you a small taste:

You see Gorilla-REPL embedded in a webapp (Alfresco Repository). The former already supports embedding pretty much out of the box – if you are ok with the fact that it brings its own http service on a dedicated port. I came up with some tweaks allowing it to be „truly“ embedded in its host – without opening a dedicated port and playing with its host app environment (servlet filters/security and things along those lines!) and firewalls ?. At this time, the idea is to build a generic drop-in jar that gives you a REPL in any(!) JEE webapp with a minimum of effort. Things are still moving quite fast and current code is based on fragile forks of snapshots, so I am not quite ready to offer a release yet. But I think we are pretty close.

References