TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

REPL vs CLI: IDE wars

147 pointsby vlaaadalmost 4 years ago

10 comments

smwalmost 4 years ago
I think you might be missing the main &quot;aha!&quot; of clojure REPLs vs REPLs in non-homoiconic languages: you can very easily execute small parts of the program you&#x27;re editing without re-typing the code.<p>In emacs, for instance, you often use `eval-last-sexp`, by default bound to C-x C-e. This lets you move your cursor to a particular point in the file, often deep in a function, and get the results of just the form(s) you&#x27;re pointing at.<p>This is a superpower! It lets you test small pieces of your code without writing any test harnesses or scaffolding. Try it with an editor that embeds the repl and has these commands, and you&#x27;ll never want to develop any other way.<p>It does cause you to want to structure your code in &#x27;repl-friendly&#x27; ways, so that you can, say, restart your main server or reset your state without restarting the whole process.
评论 #27699793 未加载
评论 #27701618 未加载
评论 #27699611 未加载
评论 #27700072 未加载
评论 #27704531 未加载
评论 #27706020 未加载
评论 #27700118 未加载
评论 #27702163 未加载
tomconnorsalmost 4 years ago
This post could be summarized as &quot;write as much of your project&#x27;s tooling as you can in the project&#x27;s main programming language and the project&#x27;s main programming language should be Clojure&quot; and I agree wholeheartedly.
评论 #27699436 未加载
评论 #27700124 未加载
geokonalmost 4 years ago
Thanks for introducing me to `add-lib` This is going to be a huge time saver :) More info here: <a href="https:&#x2F;&#x2F;insideclojure.org&#x2F;2018&#x2F;05&#x2F;04&#x2F;add-lib&#x2F;" rel="nofollow">https:&#x2F;&#x2F;insideclojure.org&#x2F;2018&#x2F;05&#x2F;04&#x2F;add-lib&#x2F;</a><p>Hopefully there will be some way to just &quot;reload&quot; your whole `deps.edn` though<p>&quot;If you get an error, the execution stops by default and you get a stack trace.&quot;<p>I&#x27;d say the other missing piece of REPL development is that while you get a stack trace, you don&#x27;t get a program state like you do with GDB or ELisp. Maybe I&#x27;m &quot;holding it wrong&quot; but this causes a lot of friction and lost time. I&#x27;d be curious how others approach this. And that all being said, the CLI doesn&#x27;t relaly offer a better alternative here.<p>For entirely replacing the CLI I think that since Clojure is a general purpose language there ends up being a tad more boiler plate than you&#x27;d like.. It&#x27;s not at the point where you&#x27;re gunna just run `clj`, load in some library with `add-lib` and start messing around b&#x2F;c things are just a tad too clunky.<p>For instance if you wanna read in a CSV file (I had to look this up)<p><pre><code> (-&gt; &quot;my-csv-file.csv&quot; (io&#x2F;file) (.getCanonicalPath) (io&#x2F;reader) (csv&#x2F;read-csv :separator \,) (#(into [] %))))) </code></pre> Uhh.. so you&#x27;re prolly gunna want to wrap that up in a helper function. I personally end up making a dummy &quot;project&quot; where I keep a bunch of helper functions and then doing my REPL &quot;scripting&quot; and messing around in that. It feels a bit wrong.. but at least to me it looks like a solvable limitation. Given a nice set of helper libraries you could probably get to a point where a bare `clj` REPL would be as ergonomic as a more explicitely interactive language like R&#x2F;MATLAB&#x2F;etc.
评论 #27700373 未加载
评论 #27702247 未加载
评论 #27700293 未加载
godshatteralmost 4 years ago
&gt; Don’t forget the set -euo pipefail at the beginning of your script. What does -euo means? I don’t know, I copy-pasted it and man set said there is no manual entry for set.<p>Use &quot;man bash&quot; to find the list of built-in commands. Scroll <i>way</i> down, or search for &quot;SHELL BUILTIN COMMANDS&quot;.<p>The &quot;e&quot; command-line switch to the set command tells the script to exit immediately if there is a non-zero return value. The &quot;u&quot; switch tells the shell to treat unset variables as errors when performing parameter expansion. The &quot;o&quot; switch enables the following option (in this case &quot;pipefail&quot;). &quot;pipefail&quot; tells the script to return the value of the rightmost command that returned with a non-zero value in a pipeline. This is all paraphrased, the details are in the man page.
评论 #27703810 未加载
评论 #27700767 未加载
lateusernamealmost 4 years ago
Considering its ecosystem, what do most here use Clojure for or what do you think is its sweet spot? I used it in a project with pg&#x2F;ring&#x2F;reitit and while some things were nicer it was not better enough to make me switch from pg&#x2F;nodejs&#x2F;express for new projects. Used emacs with inf-clojure (found cider too bloated and buggy, was tempted to port some features of cider to a fork of inf-clojure) and macros were helpful in a couple of places, but other than that, you can write JS almost as how most use Clojure. Also found JS to be faster unless you got out of your way to write Javaish Clojure, which reminds that is was a time sink having to deal with Java libs(it&#x27;s really not as &quot;seamless&quot; as most advertise) because of no Clojure equivalents.
评论 #27701524 未加载
评论 #27701792 未加载
dgb23almost 4 years ago
Some Clojure frameworks and libs do provide REPL support for things that we would otherwise expect to be CLIs, such as running migrations, (re-)starting services and so on.<p>The startup time criticism is valid, but in context of development you typically don’t restart it except you pull in deps (very rare) or something terrible happens (rare).<p>Then, there is also borkdude&#x2F;babashka which is a Clojure powered scripting tool with fast startup times due to GraalVM.
dig1almost 4 years ago
&gt; I use add-lib branch of tools.deps.alpha that allows me to add dependencies dynamically at the REPL and then start using them immediately, just like in the shell.<p>You could do this with (battle-tested) pomegranate [1] ages ago, which is used by leiningen as the default resolver.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;clj-commons&#x2F;pomegranate" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;clj-commons&#x2F;pomegranate</a>
jefuriialmost 4 years ago
Linked to in the article: UNIX as IDE (<a href="https:&#x2F;&#x2F;blog.sanctum.geek.nz&#x2F;series&#x2F;unix-as-ide&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.sanctum.geek.nz&#x2F;series&#x2F;unix-as-ide&#x2F;</a>)
a-dubalmost 4 years ago
protip; you can bring this flow to any language with a repl using vim-slime and a terminal manager like tmux.
评论 #27701838 未加载
airockeralmost 4 years ago
REPL will not work well with multitheading&#x2F;futures in Clojure.
评论 #27704747 未加载