emacs/var/elfeed/db/data/be/be4e2850ea6589036e84949819184e6feccb119e
2022-01-03 12:49:32 -06:00

62 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>nREPL 0.9 is out! Weve been working on it for over a year, but we finally
got where we wanted to be.</p>
<p>The highlight of the release is undoubtedly the support for <a href="https://en.wikipedia.org/wiki/Unix_domain_socket">Unix file sockets</a>,
which are a secure and fast alternative to TCP sockets for local development.
This feature was on the books for a very long time, but it became viable only
recently when Java 16 added support for Unix sockets.<sup id="fnref:1"><a class="footnote" href="https://metaredux.com/posts/2021/12/12/nrepl-0-9.html#fn:1" rel="footnote">1</a></sup> If youre stuck with an
older version of Java weve got you covered as well - just add <a href="https://kohlschutter.github.io/junixsocket/">junixsocket</a> as a dependency and nREPL will pick it up
automatically. With <code class="language-plaintext highlighter-rouge">tools.deps</code> you can do something like:</p>
<div class="language-clojure highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="c1">;; ...</span><span class="w">
</span><span class="no">:aliases</span><span class="w"> </span><span class="p">{</span><span class="no">:nREPL</span><span class="w">
</span><span class="p">{</span><span class="no">:extra-deps</span><span class="w">
</span><span class="c1">;; UNIX domain socket support was added in 0.9.0</span><span class="w">
</span><span class="p">{</span><span class="n">nrepl/nrepl</span><span class="w"> </span><span class="p">{</span><span class="no">:mvn/version</span><span class="w"> </span><span class="s">"0.9.0"</span><span class="p">}</span><span class="w">
</span><span class="n">com.kohlschutter.junixsocket/junixsocket-core</span><span class="w"> </span><span class="p">{</span><span class="no">:mvn/version</span><span class="w"> </span><span class="s">"2.3.2"</span><span class="p">}}}}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>Afterwards you can start nREPL like this:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>clj <span class="nt">-M</span>:nREPL <span class="nt">-m</span> nrepl.cmdline <span class="nt">--socket</span> nrepl-socket
</code></pre></div></div>
<p>CIDER has already added experimental support for Unix sockets and I hope that other
nREPL clients will follow suit soon.<sup id="fnref:2"><a class="footnote" href="https://metaredux.com/posts/2021/12/12/nrepl-0-9.html#fn:2" rel="footnote">2</a></sup> The changes necessary to clients are tiny, as only
the connection mechanism changes, everything else stays exactly the same as with TCP sockets. The magic happens in <a href="https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/socket.clj">nrepl.socket</a>, which serves as a compatibility layer for <code class="language-plaintext highlighter-rouge">java.io</code> and <code class="language-plaintext highlighter-rouge">java.nio</code>.</p>
<p>If youre not familiar with Unix sockets you might be wondering if this is something that is relevant for you. Ill try to explain the impact of Unix sockets here briefly:</p>
<ul>
<li>UNIX domain sockets know that theyre running locally, so they
can avoid some checks and operations (like routing), which makes them faster and
lighter than TCP/IP sockets.</li>
<li>You cant accidentally start an nREPL server thats listening on a public address and allows external parties to execute <strong>any</strong> code on your computer.</li>
<li>Security/access is enforced via file permissions.</li>
<li>For clients its easier to start a server and connect to it, because they dont have to deal with a random port that they have to figure out once the server starts. E.g. <code class="language-plaintext highlighter-rouge">cider-jack-in</code> can just select some socket name based on the current project and connect to it immediately.</li>
<li>They are not supported on Windows. No surprise here given their name, right?</li>
</ul>
<p>In practice all of this means that Unix sockets are generally a better option for local development than TCP sockets. Youre free to keep using TCP sockets, though, and they will always be the default in nREPL.</p>
<p>The 0.9 release also brings a bunch of small improvements and bug-fixes. One more thing - now its possible to use nREPL with GraalVM native images. Read the <a href="https://github.com/nrepl/nrepl/releases/tag/0.9.0">release notes</a> for all the details.</p>
<p>As usual, here Ill thank all the people who contributed to the release in one way or another. You rock and you show why the Clojure community is so awesome! Another round of special thanks goes to Clojurists Together and Cognitect, the main patrons of my open-source Clojure work!</p>
<p>Whats next? Time will tell. It seems that nREPL is feature-complete at this point and that weve made good on all the promises we made several years ago when nREPLs
development moved away from Clojure Contrib. Other than polishing the existing functionality, the nREPL protocol specification and the documentation theres nothing major I want to tackle at this point. Perhaps its time for a 1.0 release?</p>
<p>In parentheses we trust!</p>
<div class="footnotes">
<ol>
<li id="fn:1">
<p>Remember that nREPL cant have any runtime dependencies, so were limitted to whats available in the JDK and Clojure. <a class="reversefootnote" href="https://metaredux.com/posts/2021/12/12/nrepl-0-9.html#fnref:1">↩</a></p>
</li>
<li id="fn:2">
<p>See <a href="https://github.com/clojure-emacs/cider/pull/3088">https://github.com/clojure-emacs/cider/pull/3088</a> for more details. <a class="reversefootnote" href="https://metaredux.com/posts/2021/12/12/nrepl-0-9.html#fnref:2">↩</a></p>
</li>
</ol>
</div>