Upgrade to Pro — share decks privately, control downloads, hide ads and more …

nREPL Redux (DCD 2019)

nREPL Redux (DCD 2019)

Slide-deck from my presentation at Dutch Clojure Days 2019.

Bozhidar Batsov

April 06, 2019
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. M-x

  2. adjective 1. brought back, revived Emacs era redux 2. (usually

    postpositive) (esp of an artistic work) presented in a new way Apocalypse Now Redux
  3. Project Goals •Common foundation for Clojure tooling •Trivial to embed

    •Zero runtime dependencies •Extremely simple wire format •Easy to extend with additional functionality
  4. •Contributor Agreement •No Pull Requests •JIRA for issue tracking •Hudson

    CI •Maven •Artifacts are deployed to Maven Central
  5. 25% 5% 70% Yes Maybe I already have Notepad No

    Do you want great Clojure development tools?
  6. 69% 25% 5% 1% Yes Maybe I already have Notepad

    No Are you willing to work on Clojure development tools?
  7. Migration Strategy • Teach most extensions about both versions of

    nREPL • Migrate tools like Lein and Boot to the new nREPL • Provide ways for users of older Boot/Lein to run the new nREPL • Drop support for tools.nrepl from the extensions • Document nREPL extensively in the process • Focus on actual nREPL improvements
  8. Clear Compatibility Policy • All supported LTS JDKs (Currently Java

    8 and Java 11) • Latest rapid cycle JDK (Currently Java 12) • Clojure 1.7+ • Extreme dedication to protocol compatibility • Surgical changes at the implementation-level
  9. •Simpler code evaluation model •Robust handling of Clojure’s special variables

    •Massively improved value printing logic •Better way to hook into evaluation errors •Global/project server configuration via configuration files •Reusable command-line API
  10. •bundled with Clojure & ClojureScript •streaming REPL •a socket based

    version of the default REPL •easy if you want to evaluate something in a remote app •can be started with a JVM property •hard to build tools on it
  11. $ clj -J-Dclojure.server.jvm="{:port 5555 :accept clojure.core.server/repl}” $ nc localhost 5555

    user=> (+ 10 10) 20 user=> (println "Hello, world!") Hello, world! nil
  12. $ clj -J-Dclojure.server.jvm="{:port 5555 :accept clojure.core.server/io-prepl}” $ nc localhost 5555

    (+ 10 10) {:tag :ret, :val "20", :ns "user", :ms 23, :form "(+ 10 10)”} (println "Hello, world") {:tag :out, :val "Hello, world\n"} {:tag :ret, :val "nil", :ns "user", :ms 8, :form "(println \"Hello, world\")"}
  13. •based on the socket REPL •allows clients to customize the

    REPL •has a sophisticated rich data printer •streaming input, framed EDN output
  14. Language Server Protocol • Language agnostic • Doesn’t rely on

    a running REPL • A much broader protocol (completions, code lookup, etc) • Usually is implemented in terms of static analysis • Message oriented, JSON data format • Extensible protocol • Controlled by an evil corporation turned good
  15. • designed to power programmings tools • message oriented •

    can be extended with arbitrary operations • interruptible evals • session multiplexing • supports arbitrary communication protocol/data format • async in nature
  16. ;; request {:id "1" :op "eval" :code "(+ 1 1)”

    :ns "user"} ;; response {:id "1" :value "2"}
  17. ;; request {:id "1" :op "complete" :thing "map” :ns "user"}

    ;; response {:id "1" :candidates […]}
  18. ;; raw request {:id 1 :op "eval" :code "(+ 1

    1)"} ;; encoded request “d4:code7:(+ 1 1)2:idi1e2:op4:evale"
  19. “d4:code7:(+ 1 1)2:idi1e2:op4:evale" •d (dictionary) •4:code - a 4 byte

    string “code” •7:(+ 1 1) - a 7 byte string “(+ 1 1)” •2:id - a 2 byte string “id” •i1e - an integer 1 •… •e - end of dictionary
  20. nREPL implementations •HyREPL - an nREPL for the Hy programming

    language •JeeJah - an nREPL server for Fennel and Lua •Ogion - an nREPL server for Racket •Chicken NREPL - an nREPL server for Chicken Scheme •cl-nrepl - an nREPL server for Common Lisp •cljs-noderepl - an nREPL server for ClojureScript running on Node.js •R-nREPL - an nREPL server for R •nREPL CLR - an nREPL server for ClojureCLR •Arcadia nREPL - an nREPL server implemented in C# for Arcadia.
  21. Dreams for the future • nREPL implemented in ClojureScript/ClojureCLR •

    nREPL for Erlang/Elixir • nREPL for Smalltalk • Better behaved nREPL clients (ones that don’t make assumptions they are dealing with a Clojure server)
  22. Roadmap for nREPL 0.7 •EDN Transport (done) •Client-side resource/class injection

    API (unrepl) •Upgrade socket REPL to nREPL (unrepl) •Rich data printer (unrepl)