5 ms·
But repl workflows are not special to Clojure and Scheme. People in JS set breakpoints in their IDE, pause at a point in their script to interactively explore p
by threatofrain 5y ago
But repl workflows are not special to Clojure and Scheme. People in JS set breakpoints in their IDE, pause at a point in their script to interactively explore program state all the time.
Is this not the same?
- gotts 5y ago>Is this not the same? not even close, no
- joshlemer 5y agoI'm also curious, I think what it comes down to is that Clojure lets you change the code of a running application, rather than reload it.
- jimbob45 5y agoYou can do that with C# in Visual Studio though.
- Nihilartikel 5y agoThe greater Clojure hot-reload super power comes from embracing the idiomatic division of state and function though. Hot reload in C# will have probably have to re-instantiate classes or restart the app. In clj, if your application state is kept in a global atom a'la (defonce app-state (atom {})) Then redefining your functions won't touch your data. The only reason to do a full restart would be if you changed the data structure expected by the functions in a way that's not semantically backwards compatible. Big-whoop on a stateless webserver, maybe, but on the front end using ClojureScript for an SPA it is nothing short of magical and has ruined any other browser dev work flow for me.
- mikelevins 5y ago...and Common Lisp and Smalltalk take it a step further. You can go ahead and change the data structure in a way that's semantically incompatible. The runtime will notice that the definition has changed and either automatically reinitialize any existing instances to conform to the new definition, or, if it doesn't know how to do that, pose a UI asking you to tell it how. And when control reaches a function that expects the old kind of object and runs into an error, it'll enter a breakloop that you can use to modify the now-out-of-date function to handle the new definition properly. Once you've redefined the function you can then tell the runtime to resume and it will proceed as if the function you called had originally had the new definition.
- mumblemumble 5y agoIt is not quite the same. I'd argue that, while browser environments are very good, they're trying to solve a slightly different problem, and the overlap in capabilities is less than complete. Lispers sometimes say that the browser devtools experience is about halfway toward the power of a good Lisp environment, but I would argue that the converse is also true.
- hencq 5y agoPart of it is cultural I think. In Clojure you'll often find yourself building your app incrementally, sending individual functions to the repl from your editor. I don't think there's any reason why you couldn't do that in Javascript. Common Lisp takes this to another level though with stuff like restarts. Where the app will throw an exception during development (perhaps because a function isn't implemented yet) and instead of crashing you'll end up in the repl where you can make some fixes and keep running the app.
- susam 5y agoThere is a nice little story in the book Practical Common Lisp (Peter Seibel, 2005). Quoting it below: An even more impressive instance of remote debugging occurred on NASA's 1998 Deep Space 1 mission. A half year after the space craft launched, a bit of Lisp code was going to control the spacecraft for two days while conducting a sequence of experiments. Unfortunately, a subtle race condition in the code had escaped detection during ground testing and was already in space. When the bug manifested in the wild--100 million miles away from Earth--the team was able to diagnose and fix the running code, allowing the experiments to complete. One of the programmers described it as follows: Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem.
- CodeGlitch 5y agoI've heard this before and it does sound like the most epic hack in the history of programming.
- e12e 5y ago> 100 million miles That looks like about 9 light minutes away, so about 18 minute latency? It might be super epic, but doesn't sound super nice :)
- Qem 5y agoRecently there was a bit of a fuss when people discovered the Mars Ingenuity helicopter runs python3. Now I wonder, if its software ever crashes, will people be able to just launch the python REPL and debug It?
- _peeley 5y agoNot really. With Clojure you don't even have to leave your editor (I use Emacs with the fantastic CIDER package). You can put your cursor over an S-expression, hit two keys, and evaluate and see the results of the S-expression directly within the text buffer. The feedback loop is so quick it's basically instant - even tabbing over to a browser or terminal window feels lethargic in comparison. I haven't used Common Lisp much, but I've seen a few really impressive demos of debugging in its available REPLs. This is a longer one, but a good tour of SLIME (also an Emacs package): https://youtu.be/_B_4vhsmRRI https://youtu.be/_B_4vhsmRRI
- user3939382 5y agoIn PhpStorm I hit a hotkey to set a break point, then a hotkey to make the API call to that code and immediately get an xdebug breakdown of the entire state of the program at that point. It’s almost instantaneous and I don’t have to switch windows. I would say that’s pretty close, although the upfront learning and config to get that working means it is higher overhead overall.
- slifin 5y agoFor context I use phpstorm and Clojure Here is a video I recorded which hopefully demonstrates just how much faster you can go in Clojure https://youtu.be/L0af0bc5Jec https://youtu.be/L0af0bc5Jec Like I think a parent comment said it's hard to explain but once you get it, it's fun malable and exploratory Intellji also has a debugger that works with Clojure for when it's appropriate In php you can't redefine a function at runtime without something like runkit, in Clojure you can fix your systems at runtime
- phyrex 5y agoIt really isn’t and I suggest you give clojure an honest try to see why. It’s really hard to explain.
- patrec 5y agoMikel Evins has written two articles you might find interesting: https://mikelevins.github.io/posts/2020-12-18-repl-driven/ https://mikelevins.github.io/posts/2020-12-18-repl-driven/ https://mikelevins.github.io/posts/2020-02-03-programming-as-teaching/ https://mikelevins.github.io/posts/2020-02-03-programming-as...