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.

1be785d1d788b82929e55fc83a9f0aaa?s=128

Bozhidar Batsov

April 06, 2019
Tweet

Transcript

  1. M-x

  2. M-x greet-audience

  3. Божидар

  4. Bug cool

  5. None
  6. Sofia, Bulgaria Sofia, Bulgaria

  7. None
  8. None
  9. None
  10. We’re not hiring!

  11. None
  12. @bbatsov

  13. metaredux.com

  14. emacsredux.com

  15. None
  16. slide intentionally left blank

  17. nREPL REdux

  18. Dictionary Definitions

  19. nREPL

  20. network REPL

  21. redux

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

    postpositive) (esp of an artistic work) presented in a new way Apocalypse Now Redux
  23. nREPL Redux?

  24. nREPL is legacy

  25. nREPL is complex

  26. (nREPL) middleware sucks

  27. Rich hates nREPL

  28. The Socket REPL is the future

  29. unrepl is the future

  30. prepl is the future

  31. LSP is the future

  32. notorious REPL

  33. nice REPL

  34. neo REPL

  35. noble REPL

  36. novel REPL

  37. mREPL

  38. mega REPL

  39. mighty REPL

  40. magic REPL

  41. magnificent REPL

  42. marvellous REPL

  43. majestic REPL

  44. Naming is hard!

  45. nREPL REdux

  46. nREPL is very actively maintained

  47. nREPL is not complex

  48. Simple by design

  49. nREPL is superbly documented

  50. None
  51. Middleware is a very powerful concept

  52. A huge ecosystem of tools exists around nREPL

  53. lein repl

  54. boot repl

  55. vim-fireplace

  56. vim-iced

  57. acid.vim

  58. Calva (VS Code)

  59. Proto REPL (Atom)

  60. Cursive

  61. None
  62. A REPL for (Great) Good

  63. 2010

  64. vim-clojure custom SLIME swank Enclojure custom CCW custom

  65. vim-clojure nREPL SLIME nREPL Enclojure nREPL CCW nREPL

  66. Project Goals •Common foundation for Clojure tooling •Trivial to embed

    •Zero runtime dependencies •Extremely simple wire format •Easy to extend with additional functionality
  67. vim-fireplace nREPL CIDER nREPL Cursive nREPL CCW nREPL vim-iced nREPL

    Calva nREPL acid.vim nREPL Proto REPL nREPL
  68. None
  69. Clojure Contrib

  70. org.clojure/tools.nrepl

  71. •Contributor Agreement •No Pull Requests •JIRA for issue tracking •Hudson

    CI •Maven •Artifacts are deployed to Maven Central
  72. None
  73. 010101010101010110

  74. The (REPL) Wasteland

  75. github.com/clojure/tools.nrepl Repo deprecation announcement

  76. None
  77. 17 contributors in 8 years

  78. Almost no activity since 2015

  79. 25% 5% 70% Yes Maybe I already have Notepad No

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

    No Are you willing to work on Clojure development tools?
  81. SLIME -> CIDER

  82. CIDER loves nREPL

  83. None
  84. None
  85. Rogue One

  86. Challenges

  87. I didn’t really know what I had signed up for

  88. Breaking changes to one of the most widely used tools

    in the Clojure ecosystem
  89. org.clojure/tools.nrepl -> nrepl/nrepl

  90. clojure.tools.nrepl.* -> nrepl.*

  91. A ton of 3rd party tools and libraries needed to

    be updated
  92. •lein •boot •figwheel •shadow-cljs •REPLy •Ultra •All nREPL extensions in

    existence…
  93. •piggieback •cider-nrepl •refactor-nrepl •sayid •drawbridge •and many others…

  94. 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
  95. Building a community around the project

  96. A Catalyst for Change

  97. REPL (R)Evolution

  98. •nREPL 0.3 (initial compatibility release) •nREPL 0.4 (multiple feature releases)

    •nREPL 0.5 •nREPL 0.6
  99. Better Versioning Policy

  100. 0.feature.patch

  101. Then •0.2.5 (Feature) •0.2.6 (Feature) •0.2.7 (Bug fix) •0.2.8 (Feature)

  102. Now •0.5.0 (Feature) •0.5.1 (Bug fix) •0.5.2 (Bug fix) •0.6.0

    (Feature)
  103. 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
  104. Fixed many long-standing bugs

  105. Complete overhaul of the internals

  106. •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
  107. Exhaustive documentation (nrepl.org)

  108. Great integration with tools.deps

  109. Transit transport (https://github.com/nrepl/fastlane)

  110. EDN transport (coming in nREPL 0.7)

  111. Support for hot-loading libraries in a running REPL

  112. No breaking changes to the protocol

  113. Minimal breaking changes on the API level

  114. Team-work FTW

  115. Chas creates the new repo Rogue One

  116. None
  117. 23 new contributors!

  118. Christophe Grand

  119. Michael Griffiths

  120. None
  121. None
  122. Monopoly is good

  123. Monopoly allows you to focus on innovation

  124. Meet The Competition

  125. The Socket REPL

  126. •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
  127. $ 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
  128. prepl

  129. $ 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\")"}
  130. unrepl

  131. •based on the socket REPL •allows clients to customize the

    REPL •has a sophisticated rich data printer •streaming input, framed EDN output
  132. 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
  133. None
  134. Swiss army knife of REPLs

  135. • 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
  136. ;; request {:id "1" :op "eval" :code "(+ 1 1)”

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

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

    1)"} ;; encoded request “d4:code7:(+ 1 1)2:idi1e2:op4:evale"
  139. “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
  140. Community Driven

  141. Open Source is not about You

  142. nREPL is all about YOU!!!

  143. Beyond Clojure

  144. nREPL as a protocol

  145. Simple by design

  146. Key Operations •eval •load-file •interrupt •stdin

  147. Bencode Data Types •strings •integers •lists •maps

  148. None
  149. A light-weight alternative to LSP

  150. Easy to implement

  151. 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.
  152. 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)
  153. (next nrepl)

  154. 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)
  155. Personal Impact

  156. Extremely proud

  157. None
  158. Frustrated

  159. Tired

  160. Burned out

  161. None
  162. None
  163. None
  164. Sustainable

  165. Community Funded?

  166. Clojure’s Orchard

  167. $4000

  168. $5400

  169. We need to get Clojure companies invested in the Clojure

    tooling ecosystem
  170. 20 companies paying $500/month can make a massive difference

  171. Funding channels •https://opencollective.com/nrepl •https://opencollective.com/cider •https://patreon.com/bbatsov •https://paypal.me/bbatsov

  172. Help nREPL…

  173. …to help yourselves

  174. –Old Dutch Saying “You can’t build an epic Clojure programming

    experience on top of a poor REPL.”
  175. Felina

  176. Resources • https://metaredux.com/posts/2018/10/29/nrepl-redux.html • https://metaredux.com/posts/2019/01/12/nrepl-beyond- clojure.html • https://metaredux.com/posts/2019/03/29/nrepl-0-6.html • https://www.youtube.com/watch?v=4X-1fJm25Ww

  177. Credits twitter: @bbatsov github: @bbatsov https://metaredux.com https://emacsredux.com DCD 2019 Amsterdam,

    The Netherlands 06.04.2019