Save 37% off PRO during our Black Friday Sale! »

CIDER: Rocking with Clojure and Emacs

CIDER: Rocking with Clojure and Emacs

Slide deck from my buildstuff.lt 2015 presentation.

Efd2550fb5f3059d815e731ecd61b701?s=128

Bozhidar Batsov

November 20, 2015
Tweet

Transcript

  1. CIDER: Rocking with Clojure and Emacs narrated by Bozhidar I.

    Batsov
  2. Sveiki!

  3. į sveikatą!

  4. @bbatsov

  5. Bulgaria

  6. None
  7. Bug

  8. None
  9. None
  10. A (Dark) Knight of the Order of Emacs

  11. None
  12. None
  13. Why I am here?

  14. I am a storyteller!

  15. None
  16. A story about a different kind of cider…

  17. Which is your primary Clojure dev environment? (2014) Other 13%

    LightTable 12% CCW 5% fireplace 14% Cursive 14% CIDER 42%
  18. –Nancy Pearcey “Competition is always a good thing. It forces

    us to do our best. A monopoly renders people complacent and satisfied with mediocrity.”
  19. Near future Others 10% CIDER 90%

  20. Near future Cursive 25% Others 15% CIDER 60%

  21. A not so long time ago in a galaxy not

    far away…
  22. Java, C# and PHP ruled the dev world

  23. The Lisp Masters from the Republic of Great Programmers were

    on the run
  24. Lisps were out of fashion

  25. 2007

  26. A gentleman & a scholar

  27. Clojure

  28. Biggest Clojure problem at launch?

  29. ((((((((((()))))))))))

  30. 0 Clojure development environments

  31. Emacs was the last Lisp stronghold

  32. Emacs is the greatest Emacs Lisp dev environment

  33. SLIME

  34. Superior Lisp Interaction Mode for Emacs

  35. SLIME Features • REPL • Interactive evaluation • Compilation notes

    • Code completion • Definition lookup • Documentation lookup • Apropos
  36. SLIME Features • Debugger • Value inspector • Tracing •

    Find usages • Macroexpansion • Scratchpad • Minibuffer code evaluation
  37. SLIME is an IDE

  38. Interactive Development Environment

  39. Programs are built in a very incremental manner

  40. SLIME (Emacs Lisp) SWANK (Common Lisp) Clozure RPC LispWorks CMUCL

    ABCL SBCL Client Server Backends
  41. 2008

  42. clojure-mode & swank-clojure

  43. SLIME (Emacs Lisp) SWANK (Common Lisp) swank-clojure

  44. A star was born

  45. swank-clojure • Requires knowledge of swank (Common Lisp) • Bundles

    a frozen SLIME version • Subpar features (e.g. debugger, inspector, find usages) • Monolithic (no swank plugins)
  46. SLIME is a Common Lisp tool

  47. 2010

  48. Another esteemed gentleman & scholar

  49. nREPL

  50. A common foundation for Clojure development tools

  51. •Load (compile) a Clojure source file •Evaluate a Clojure form

    •Interrupt evaluation •Read from the standard input
  52. Extensible via middleware

  53. 2012

  54. nrepl.el

  55. nrepl.el (Emacs Lisp) nREPL (Clojure)

  56. A workhorse is retired

  57. nrepl.el • lacked many SLIME features • relied heavily on

    evaluation of inlined code • made assumptions about the environment • flawed bencode parser
  58. 2013

  59. Don’t settle for good. Demand great!

  60. –Phil Karlton “There are only two hard things in Computer

    Science: cache invalidation and naming things.”
  61. None
  62. Clojure Integrated Development Environment & REPL

  63. Clojure Interactive Development Environment Reimagined

  64. Clojure Interactive Development Environment that Rocks

  65. None
  66. (defun nrepl-jump-to-def (var) "Jump to the definition of the VAR

    at point." (let ((form (format "(let [ns-symbol '%s ns-var '%s ns-file (clojure.core/comp :file clojure.core/meta clojure.core/second clojure.core/first clojure.core/ns-publics) resource-str (clojure.core/comp clojure.core/str clojure.java.io/resource ns-file) file-str (clojure.core/comp clojure.core/str clojure.java.io/file ns-file)] (cond ((clojure.core/ns-aliases ns-symbol) ns-var) (let [resolved-ns ((clojure.core/ns-aliases ns-symbol) ns-var)] [(resource-str resolved-ns) (file-str resolved-ns) 1]) (find-ns ns-var) [(resource-str ns-var) (file-str ns-var) 1] (clojure.core/ns-resolve ns-symbol ns-var) ((clojure.core/juxt (clojure.core/comp clojure.core/str clojure.java.io/resource :file) (clojure.core/comp clojure.core/str clojure.java.io/file :file) :line) (clojure.core/meta (clojure.core/ns-resolve ns-symbol ns-var)))))" (nrepl-current-ns) var))) (nrepl-send-string form (nrepl-jump-to-def-handler (current-buffer)) nrepl-buffer-ns (nrepl-current-tooling-session)))) not portable
  67. (defun cider-jump-to-var (&optional var line) "Jump to the definition of

    VAR, optionally at a specific LINE. When called interactively, this operates on point, or falls back to a prompt." (interactive) (cider-ensure-op-supported "info") (cider-read-symbol-name "Symbol: " (lambda (var) (-if-let (info (cider-var-info var)) (cider--jump-to-loc-from-info info) (message "Symbol %s not resolved" var))))) portable
  68. CIDER Features • Interactive evaluation • Compilation notes • Code

    completion • Definition lookup • Documentation lookup • Apropos
  69. CIDER Features • Value inspector • Command selector • Tracing

    • Macroexpansion • Debugger • Scratchpad • Minibuffer code evalution
  70. CIDER Features • Javadoc support • Jump to Java definition

    • Jump to resource • Sanity-preserving stacktraces • clojure.test integration • namespace browser
  71. CIDER Features • classpath browser • grimoire integration • dynamic

    indentation • dynamic font-locking • nREPL session manager • Smart namespace reloading • ClojureScript support
  72. Extensions (are easy)

  73. Refactoring support (clj-refactor + refactor-nrepl)

  74. Demo Time

  75. CIDER tastes better than SLIME

  76. CIDER tastes better than some IDES

  77. What’s still missing?

  78. • Find usages • Built-in refactoring tooling • Better ClojureScript

    support • Support for the new Clojure socket REPL • A proper manual CIDER 1.0
  79. Why CIDER?

  80. Integrated Development Environment (a.k.a. IDE)

  81. None
  82. Emacs

  83. None
  84. None
  85. None
  86. None
  87. None
  88. Spacemacs

  89. Emacs users know how to build productive Lisp workflows

  90. •Emacs (ultimate Elisp dev env) •SLIME (and SLY) •Geiser •racket-mode

    •CIDER (obviously)
  91. • paredit • smartparens • rainbow-delimiters • rainbow-identifiers • sexp-fu

    • paxedit • lispy
  92. Community impact

  93. cider-nrepl https://github.com/clojure-emacs/cider-nrepl

  94. refactor-nrepl https://github.com/clojure-emacs/refactor-nrepl

  95. compliment https://github.com/alexander-yakushev/compliment

  96. cljs-tooling https://github.com/gtrak/cljs-tooling

  97. nREPL improvements

  98. Open development

  99. None
  100. None
  101. 126 contributors!

  102. Please, send more help!

  103. Thanks!

  104. Felina