News for hackers. Stuff that matters.
Re:On Repl-Driven Programming (2020) by cobaltoxide on Thursday May 05, 2022 @06:53PM (#31279273)
A peculiar workflow of REPL-driven programming environments is that the running program is eventually "saved" by writing the state of the virtual machine to disk. There may be no source code to rebuild from, if the program was built interactively. It has its appeal, but it's kind of a nightmare from a maintainability standpoint.
Re:On Repl-Driven Programming (2020) by mikelevins on Thursday May 05, 2022 @10:02PM (#31280425)
No.

I've been doing repl-driven development with Common Lisp compilers for about 33 years now. I have never ever worked in the way that you describe, and have never witnessed anyone else working that way, either.

It would be a nightmare for maintainability if anyone worked that way, but if they do, I haven't ever seen it.

I do write the state of the runtime to image files from time to time for various purposes. I assure you, though, that all the code I write lives in files that are maintained under revision control, and it's been that way for many years, and in all that time I've never been in danger of losing any work because of forgetting to write an image file.

Re:On Repl-Driven Programming (2020) by PaulDavisThe1st on Thursday May 05, 2022 @11:51PM (#31281120)
To be fair, this general idea was at the core of how many versions of (at least GNU) emacs were created: launch minimal version, load lots of stuff, dump. Fire up dump in the future.

Nevertheless, this still does not add up to precisely what the GP described.

Re:On Repl-Driven Programming (2020) by froh on Friday May 06, 2022 @12:55AM (#31281457)
That's not for developing emacs, but for accelerating emacs startup.

Smalltalk in contrast has GP's model of saving and reloading the VM state.

Re:On Repl-Driven Programming (2020) by mikelevins on Friday May 06, 2022 @07:35AM (#31283923)
Most Smalltalk systems and most Common Lisp systems and Interlisp and Factor, and, for that matter, some Schemes and the version of Dylan that Apple used to develop the bauhaus OS, all offer the convenience of starting up from a saved image and of saving a new image to preserve incremental changes for next time.

Interlisp and most Smalltalk systems also offer the convenience of automatic change tracking, writing your changes to the sources file and the changes file, and providing in-image tools for browsing and managing changes, including things like Interlisp’s Masterscope and Pharo and Squeak’s Monticello. These tools make life more convenient for people who prefer to work mainly with the in-image tools and not to mess with text files that much.

But if there’s a Smalltalk system that relies solely on the image file to preserve changes, with no support for other means of change tracking, I’m not aware of it.

Re:On Repl-Driven Programming (2020) by pixelrevision on Friday May 06, 2022 @01:04AM (#31281506)
I’ve always been curious about this. If you are not writing out the state of the program is there some convenient way to output parts of it? The article describes adding functions and refactoring data types but if you are doing that I’d assume you’d want those changes back in your source files.
Re:On Repl-Driven Programming (2020) by igouy on Friday May 06, 2022 @01:17PM (#31287635)
> … is there some convenient way to output parts of it?

The old ways —

"Within each project, a set of changes you make to class descriptions is maintained. … Using a browser view of this set of changes, you can find out what you have been doing. Also, you can use the set of changes to create an external file containing descriptions of the modifications you have made to the system so that you can share your work with other users.

…

The storage of changes in the Smalltalk-80 system takes two forms: an internal form as a set of changes (actually a set of objects describing changes), and an external form as a file on which your actions are logged while you are working (in the form of executable expressions or expressions that can be filed into a system). … All the information stored in the internal change set is also written onto the changes file."

1984 Smalltalk-80 The Interactive Programming Environment page 461

https://rmod-files.lille.inria.fr/FreeBooks/TheInteractivePr...

The somewhat less old way —

https://www.google.com/books/edition/Mastering_ENVY_Develope...

Re:On Repl-Driven Programming (2020) by mikelevins on Friday May 06, 2022 @08:56AM (#31284562)
They always were in my source files. Nearly all of the text I type in a Lisp project is in a source file that is managed by a revision-control system. That's the way I've worked with Lisp systems for more than thirty years.

I send my changes to the repl with the stroke of a key.

Working with a repl doesn't necessarily mean typing text at a prompt. The prompt isn't the repl; it's just a particular UI for the repl.

Smalltalk systems do tend to store edits in the memory image (though they also write them automatically to a changes file and a sources file, so they aren't lost if you blow away your working image). Smalltalkers generally prefer to work in the image and treat text files as a serialization format for exchanging code and data.

But normally there's no question of getting "changes back in your source file" because they were always in your source file, or its equivalent, from the start.

Re:On Repl-Driven Programming (2020) by dunefox on Friday May 06, 2022 @02:21AM (#31281903)
> I’d assume you’d want those changes back in your source files

Not an expert, but your changes never 'leave' your source files. You iterate by changing the code in the file, sending it to the image/compiler, and repeat. There's no need for "getting code back into the files".

Re:On Repl-Driven Programming (2020) by rvense on Friday May 06, 2022 @01:42AM (#31281688)
The REPL and editor are connected. You have a key command in your editor that sends the form you want to evaluate to the REPL, which is in a separate window or pane.
Re:On Repl-Driven Programming (2020) by mikelevins on Friday May 06, 2022 @09:03AM (#31284615)
Right, except that the repl isn't in another pane; a repl prompt is.

Part of the confusion on this point is thinking that the prompt is the repl. It isn't. It's a UI for the repl. The repl is the process that reads, evaluates, and prints, then loops back to do it again.

Nothing about a repl requires there to be a prompt, and not all UIs for repls have them. Interlisp and Smalltalk have relied mainly on promptless UIs for their repls since the 1970s.

When working with Common Lisp, the main UI I use is an Emacs editor buffer and the key bindings that send input directly to the repl (bypassing the prompt). Typing at the prompt is the exception rather than the rule, and I could get along fine if I didn't bother to load the slime-repl contrib that provides it.

Re:On Repl-Driven Programming (2020) by xkriva11 on Friday May 06, 2022 @10:02AM (#31285203)
Yes, the evaluation of the code needs to be possible from everywhere. From the REPL window, the code editor, the debugger, and the inspector... Any code you select should be possible to evaluate in place.

It is more than four decades old obvious basic idea, and I do not understand why almost everybody ignores it.

Re:On Repl-Driven Programming (2020) by medo-bear on Friday May 06, 2022 @03:31AM (#31282377)
when i write cl that is precisely what i do. i imagine this is the case with everyone - ie write code into the source file and send new bits to the repl
Re:On Repl-Driven Programming (2020) by gumby on Thursday May 05, 2022 @08:46PM (#31279926)
That was true of InterLisp-D and the SmallTalk environments, but not the case of the systems that begat CommonLisp (MACLISP, the lispms, franzlisp, etc).

In other words it was a cultural thing, not a property of the languages. And even with the systems for which that was possible it was also possible to start with a fresh band and load code into it.

Re:On Repl-Driven Programming (2020) by mikelevins on Thursday May 05, 2022 @10:21PM (#31280546)
Moreover, Smalltalk and Interlisp interactions are recorded in files automatically--the changes file, the sources file, and the working image (which also contains tools--e.g. Interlisp's Masterscope--for keeping track of changes).

The notion that you'll lose your work if you use the normal means of interacting with the repl is a misunderstanding of how such systems work.

Re:On Repl-Driven Programming (2020) by ratzkewatzke on Thursday May 05, 2022 @08:00PM (#31279616)
I write Lisp for a living (in a couple of different forms), and I've never seen this. You do occasionally get problems where the state drifts a bit and you end up with order dependencies in files, but everybody I know works on source code and pushes it back and forth to the REPL via their editor.
Re:On Repl-Driven Programming (2020) by Jtsummers on Thursday May 05, 2022 @08:13PM (#31279697)
> There may be no source code to rebuild from, if the program was built interactively.

If someone did that, they'd be a fool. Common Lisp and Smalltalk, the quintessential REPL-driven languages, have supported storing and loading source from files since their standards were published, and before then since the standards weren't created out of thin air.

Re:On Repl-Driven Programming (2020) by bitwize on Thursday May 05, 2022 @10:19PM (#31280529)
Most Lispers type into source files and send the changes over to the REPL using e.g., SLIME on Emacs. Rebuilding the image from source is always possible.

Even under Smalltalk, which works more like you say, the system tracks and saves source changes. At least that's how it works under Squeak and Pharo.

Very few developers would be foolish enough to use a heap image as the source of all truth. I'm sure it happens, just like the place I worked at whose entire web stack was based on a magic DLL no one knew how to compile, happened. Like the magic DLL, it's widely considered a terrible, terrible idea.

Re:On Repl-Driven Programming (2020) by jrvarela56 on Thursday May 05, 2022 @11:17PM (#31280915)
You end up in OPs situation if you type into the REPL - which you're not supposed to.

The workflow is amazing because you write the software in the editor you're used to and have keybindings for interacting with the REPL inside your editor.