5 ms·
Might be not exactly what you ask about, but, REPL-driven development. (Though, to be more accurate, it is more of image based development, rather than REPL, wh
by sleepycatgirl 4y ago
Might be not exactly what you ask about, but,
REPL-driven development. (Though, to be more accurate, it is more of image based development, rather than REPL, which is quite big difference)
Function does not work? Change it , re-evaluate, and call the function again.
No need for constant restarting, re-compiling or so.
All on-the-fly,
Once you get used to it, it's really something else.
Its simply unique, also without sacrificing performance (Because it is quite performant)
- jstx1 4y agoDoesn't everyone in data science do this too with Python/R/Julia? I don't think that it's a unique Common Lisp feature.
- jhgb 4y agoNot quite. For example, languages like Python typically have generative class definitions -- meaning that a class definition always creates a new type, with no existing object instances being objects of that class. In comparison, Common Lisp has provisions for adapting old instances to match a new definition of an already existing class, including lazy updates. Taken to extreme, this allows for such things as large on-disk object databases (since presumably you don't want to convert a billion objects on the disk the moment you add a field to a class).
- knome 4y agoThe erlang language provides a similar facility for replacing code and updating object state without ever bringing the program to a halt.
- phoe-krk 4y agoThe main difference is that Erlang is very strict about the kind of programs it will run (purely functional green-thread-esque processes and OO systems that utilize message passing and code that is modified must be swapped in/out at strictly defined points in program lifecycle), whereas CL is a fully mutable environment where modification can happen at any time during program lifecycle. Much more powerful, which comes with benefits as much as it comes with the amount of guns to blow your feet off with.
- register 4y agoIn Python and Julia in most of the cases you have to restart ; don't know about R. In Common Lisp you can change a function that is running a loop while the loop is executing and you will see the result immediately in the next iteration after the change. As mentioned the closest thing with modern languages is JS in Chrome.
- jstx1 4y agoWhen is it useful to have a loop that executes partially with some code and the rest of the way with different code?
- kgwgk 4y agoIt's useful if you have some loop running and you want to stop it for some reason in an orderly fashion. Say you were processing several years of data but now want to stop when the first year is completed for some reason. Maybe it's taking too long and you'll rather keep working with partial results or whatever. You can easily recompile the processing function to raise an error when it reaches the stopping point. Or maybe you noticed that the loop will eventually hit an edge case which is not properly handled currently in the code. You can fix it while the loop gets there. And of course for GUI programming. You can redefine interface behaviours on the fly.
- phoe-krk 4y agoFirst example that comes to my mind: you have a game loop running and you would like to change the way the scene is rendered without restarting the game loop altogether and/or losing the current state of the game.
- mikelevins 4y agoYep, this is definitely useful. I've done this kind of work. It's much faster to build an interactive world if you can tweak everything about it while it runs and see the results instantly. The same goes for some simulations I've worked on (and am working on). It's much faster and easier to get good results if you can see the effects of your changes in real time, as the simulation runs.
- vindarel 4y agoI try to explain diffirences with Python here: https://lisp-journey.gitlab.io/pythonvslisp/ https://lisp-journey.gitlab.io/pythonvslisp/ + there is more in this thread.
- whizzter 4y agoVariations (to various degrees) are available in plenty of environments. Most powerful one today by combination is actually JS inside Chrome, you naturally have the REPL that can do things. But REPL's are good for the first prototyping whilst later on you might have modules (CL might make things inspectable?) that try to hide things (think JS/TS modules), Chrome however is pretty damn good at runtime detecting more or less incremental updates so you can just rewrite code and re-save the source files and Chrome will replace the function bodies in-situ without any state rebuilding or reloading being necessary. Of more conventional languages, MSVC has had C/C++ Edit-Continue (as long as you didn't change type/function signatures) since ca 1998, it's a descendant of this that MS was hyping last year with Hot-Reloading for C# with body replacement (on top of the interactive shell("REPL") that has been in Visual Studio for years). Especially the conventional ones might not be as flexible as the Lisp ones(but handle many practical cases fairly well) but all dynamic "scripting" languages like JS/Python/Lua,etc has been able to do most repl-y things fairly well from day 1.
- activitypea 4y agoThe Chrome console is only useful if your code doesn't get bundled, which is rare
- deleted 4y ago[deleted]
- hajile 4y agoThose REPLs aren't even remotely comparable. You can TEST with them, but you never DEVELOP with them. If they were the same, you'd load up a repl of your entire codebase. Now you'd dynamically update the part you're working on, test it live against your current environment, and finally save it to move to another thing. When errors happen, you just drop into the debugger to find the issue. If you missed a call site or two, you'll probably catch it here. Because it's instantaneous, it's not painful. I'll have a REPL open pretty much all the time when messing around with CL. In JS (my day job), this wouldn't work at present if for no other reason than directly replacing a function is impossible. You'd create a second instance of a function, but all the old references from other places in the code would remain stuck with the old version. JS falls back to "hot reloading" which is literally "restart the whole JIT" which means that you have to warm the JIT up again and (more importantly) that all your state disappears. You make a change then wait a while for everything to recompile and run. Then you have to write/execute a bunch of code to get your state back to where it was. When the error is thrown, you now have to look through the things for that call site you missed, save, and reload everything all over again. Rinse and repeat. This heavily disincentivizes interactive and incremental development in favor of massive changes then trying everything out at once.
- atgreen 4y agoYes, this exactly. If you are doing k8s-based development, where your Lisp code is participating in k8s-hosted service communication, nothing beats the CL development experience, where you just connect Emacs to your image via SLY/SLIME and make live changes in the kerbernetes cluster, but your source files are local.