Ambly and Socket REPL
Clojure 1.8.0 will be introducing a new Socket REPL capability that will make it easier to integrate tooling with REPLs. Perhaps a succinct way of looking at it, is that it is an improved take on what nREPL offers.
It turns out that this capability works just fine with ClojureScript REPLs. So I gave it a spin with Ambly, and it appears to work properly, even with Ambly's special "device discovery" CLI that occurs when it is starting up.
Here's a demo: In a Clojure REPL set up with Ambly 0.6.0, Clojure 1.8.0-RC1, and ClojureScript 1.7.170 on the classpath, issue these 3 forms:
(ns ambly-repl.core
(:require
[cljs.repl :as repl]
[ambly.core :as ambly]
[clojure.core.server :as server]))
(defn make-repl []
(repl/repl (ambly/repl-env)))
(server/start-server
{:port 51000
:name :cljs-socket-repl
:accept 'ambly-repl.core/make-repl})
Then you will see
#object[java.net.ServerSocket 0x7d4a2ef4 "ServerSocket[addr=localhost/127.0.0.1,localport=51000]"]
Then, in another terminal use telnet
as the Socket REPL client:
$ telnet 127.0.0.1 51000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
[1] Ambly Demo on Mike's iPhone
[R] Refresh
Choice: 1
Connecting to Ambly Demo on Mike's iPhone ...
To quit, type: :cljs/quit
cljs.user=> (map inc [1 2 3])
(2 3 4)
cljs.user=>
Cool! I'm communicating with Ambly over a socket, which in turn is communicating with my iPhone via TCP over WiFi. All good!
My take away is that it will be very easy to expose the capabilities of REPLs over a socket, and I'm looking forward to tooling (especially IDEs like my favorite one, Cursive) to be enhanced to support Socket REPL.