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 greet-audience

    View full-size slide

  2. Божидар

    View full-size slide

  3. Sofia, Bulgaria
    Sofia, Bulgaria

    View full-size slide

  4. We’re not hiring!

    View full-size slide

  5. metaredux.com

    View full-size slide

  6. emacsredux.com

    View full-size slide

  7. slide intentionally
    left blank

    View full-size slide

  8. Dictionary Definitions

    View full-size slide

  9. network REPL

    View full-size slide

  10. adjective
    1. brought back, revived
    Emacs era redux
    2. (usually postpositive) (esp of
    an artistic work) presented in a new way
    Apocalypse Now Redux

    View full-size slide

  11. nREPL Redux?

    View full-size slide

  12. nREPL is legacy

    View full-size slide

  13. nREPL is complex

    View full-size slide

  14. (nREPL) middleware sucks

    View full-size slide

  15. Rich hates nREPL

    View full-size slide

  16. The Socket REPL is the future

    View full-size slide

  17. unrepl is the future

    View full-size slide

  18. prepl is the future

    View full-size slide

  19. LSP is the future

    View full-size slide

  20. notorious REPL

    View full-size slide

  21. magnificent REPL

    View full-size slide

  22. marvellous REPL

    View full-size slide

  23. majestic REPL

    View full-size slide

  24. Naming is hard!

    View full-size slide

  25. nREPL is very
    actively maintained

    View full-size slide

  26. nREPL is not complex

    View full-size slide

  27. Simple by design

    View full-size slide

  28. nREPL is
    superbly documented

    View full-size slide

  29. Middleware is a
    very powerful concept

    View full-size slide

  30. A huge ecosystem of tools
    exists around nREPL

    View full-size slide

  31. vim-fireplace

    View full-size slide

  32. Calva (VS Code)

    View full-size slide

  33. Proto REPL (Atom)

    View full-size slide

  34. A REPL for (Great) Good

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  37. Project Goals
    •Common foundation for Clojure tooling
    •Trivial to embed
    •Zero runtime dependencies
    •Extremely simple wire format
    •Easy to extend with additional functionality

    View full-size slide

  38. vim-fireplace
    nREPL
    CIDER
    nREPL
    Cursive
    nREPL
    CCW
    nREPL
    vim-iced
    nREPL
    Calva
    nREPL
    acid.vim
    nREPL
    Proto REPL
    nREPL

    View full-size slide

  39. Clojure Contrib

    View full-size slide

  40. org.clojure/tools.nrepl

    View full-size slide

  41. •Contributor Agreement
    •No Pull Requests
    •JIRA for issue tracking
    •Hudson CI
    •Maven
    •Artifacts are deployed to Maven Central

    View full-size slide

  42. 010101010101010110

    View full-size slide

  43. The (REPL) Wasteland

    View full-size slide

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

    View full-size slide

  45. 17 contributors in 8 years

    View full-size slide

  46. Almost no activity since 2015

    View full-size slide

  47. 25%
    5%
    70%
    Yes Maybe
    I already have Notepad No
    Do you want great Clojure development tools?

    View full-size slide

  48. 69%
    25%
    5%
    1%
    Yes Maybe
    I already have Notepad No
    Are you willing to work on Clojure development tools?

    View full-size slide

  49. SLIME -> CIDER

    View full-size slide

  50. CIDER loves nREPL

    View full-size slide

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

    View full-size slide

  52. Breaking changes to one of the
    most widely used tools in the
    Clojure ecosystem

    View full-size slide

  53. org.clojure/tools.nrepl
    ->
    nrepl/nrepl

    View full-size slide

  54. clojure.tools.nrepl.*
    ->
    nrepl.*

    View full-size slide

  55. A ton of 3rd party tools and
    libraries needed to be updated

    View full-size slide

  56. •lein
    •boot
    •figwheel
    •shadow-cljs
    •REPLy
    •Ultra
    •All nREPL extensions in existence…

    View full-size slide

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

    View full-size slide

  58. 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

    View full-size slide

  59. Building a community
    around the project

    View full-size slide

  60. A Catalyst for Change

    View full-size slide

  61. REPL (R)Evolution

    View full-size slide

  62. •nREPL 0.3 (initial compatibility release)
    •nREPL 0.4 (multiple feature releases)
    •nREPL 0.5
    •nREPL 0.6

    View full-size slide

  63. Better Versioning Policy

    View full-size slide

  64. 0.feature.patch

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  67. 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

    View full-size slide

  68. Fixed
    many long-standing bugs

    View full-size slide

  69. Complete overhaul of the
    internals

    View full-size slide

  70. •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

    View full-size slide

  71. Exhaustive documentation
    (nrepl.org)

    View full-size slide

  72. Great integration with
    tools.deps

    View full-size slide

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

    View full-size slide

  74. EDN transport
    (coming in nREPL 0.7)

    View full-size slide

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

    View full-size slide

  76. No breaking changes to the
    protocol

    View full-size slide

  77. Minimal breaking changes on
    the API level

    View full-size slide

  78. Team-work FTW

    View full-size slide

  79. Chas creates the new repo
    Rogue One

    View full-size slide

  80. 23 new contributors!

    View full-size slide

  81. Christophe Grand

    View full-size slide

  82. Michael Griffiths

    View full-size slide

  83. Monopoly is good

    View full-size slide

  84. Monopoly allows you to
    focus on innovation

    View full-size slide

  85. Meet The Competition

    View full-size slide

  86. The Socket REPL

    View full-size slide

  87. •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

    View full-size slide

  88. $ 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

    View full-size slide

  89. $ 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\")"}

    View full-size slide

  90. •based on the socket REPL
    •allows clients to customize the REPL
    •has a sophisticated rich data printer
    •streaming input, framed EDN output

    View full-size slide

  91. 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

    View full-size slide

  92. Swiss army knife of REPLs

    View full-size slide

  93. • 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

    View full-size slide

  94. ;; request
    {:id "1"
    :op "eval"
    :code "(+ 1 1)”
    :ns "user"}
    ;; response
    {:id "1"
    :value "2"}

    View full-size slide

  95. ;; request
    {:id "1"
    :op "complete"
    :thing "map”
    :ns "user"}
    ;; response
    {:id "1"
    :candidates […]}

    View full-size slide

  96. ;; raw request
    {:id 1 :op "eval" :code "(+ 1 1)"}
    ;; encoded request
    “d4:code7:(+ 1 1)2:idi1e2:op4:evale"

    View full-size slide

  97. “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

    View full-size slide

  98. Community Driven

    View full-size slide

  99. Open Source is not about You

    View full-size slide

  100. nREPL is
    all about YOU!!!

    View full-size slide

  101. Beyond Clojure

    View full-size slide

  102. nREPL as a protocol

    View full-size slide

  103. Simple by design

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  106. A light-weight alternative to
    LSP

    View full-size slide

  107. Easy to implement

    View full-size slide

  108. 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.

    View full-size slide

  109. 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)

    View full-size slide

  110. (next nrepl)

    View full-size slide

  111. 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)

    View full-size slide

  112. Personal Impact

    View full-size slide

  113. Extremely proud

    View full-size slide

  114. Community Funded?

    View full-size slide

  115. Clojure’s Orchard

    View full-size slide

  116. We need to get Clojure companies
    invested
    in the Clojure tooling ecosystem

    View full-size slide

  117. 20 companies paying
    $500/month can make a
    massive difference

    View full-size slide

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

    View full-size slide

  119. Help nREPL…

    View full-size slide

  120. …to help yourselves

    View full-size slide

  121. –Old Dutch Saying
    “You can’t build an epic Clojure
    programming experience on top of a
    poor REPL.”

    View full-size slide

  122. 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

    View full-size slide

  123. Credits
    twitter: @bbatsov
    github: @bbatsov
    https://metaredux.com
    https://emacsredux.com
    DCD 2019
    Amsterdam,
    The Netherlands
    06.04.2019

    View full-size slide