News for hackers. Stuff that matters.
Re:On Repl-Driven Programming by alknemeyer on Sunday January 03, 2021 @05:04AM (#25620831)
For what it's worth, IPython's "autoreload" magic and Julia's "Revise" package get you _closer_ to what the author describes. In both cases, one can define functions/classes/structs in a file/module, load it in a repl, create objects etc, modify the file and have the changes propagate through to live objects
Re:On Repl-Driven Programming by globular-toast on Sunday January 03, 2021 @05:23AM (#25620907)
Closer but still so far. As soon as you have more than one module in Python it completely falls apart, despite any autoreload magic. It just isn't the same at all as REPL based programming. In Lisps you can write your entire program with an instance and a REPL running the entire time. No restarting the instance required. It works because it's just how Lisp works. A REPL is a trivial thing you can write yourself that runs in the same instance.

Whenever I think about it I can't quite put my finger on exactly what Python would need to make it the same. It's something to do with the way imports and namespaces work, though.

Re:On Repl-Driven Programming by sedachv on Sunday January 03, 2021 @05:59PM (#25626085)
> Whenever I think about it I can't quite put my finger on exactly what Python would need to make it the same. It's something to do with the way imports and namespaces work, though.

Python has a fundamentally broken module system, and Python 3 did nothing to fix it:

https://nedbatchelder.com/blog/201908/why_your_mock_doesnt_w...

https://docs.python.org/dev/library/importlib.html#importlib...

Re:On Repl-Driven Programming by globular-toast on Sunday January 03, 2021 @06:40PM (#25626385)
Right. That's it. Thanks for the links!
Re:On Repl-Driven Programming by joshlk on Sunday January 03, 2021 @05:15AM (#25620866)
You can also add breakpoints which automatically occurs when exceptions are raised. Which is similar to the breakloop functionality mentioned in the article.
Re:On Repl-Driven Programming by djm_ on Sunday January 03, 2021 @05:30AM (#25620935)
Yes, running pytest with the --pdb flag will drop you into the debugger on an unhandled exception which gets a comparable workflow but it's not quite the same as, a) writing tests to file first is not repl-driven development, and b) you generally have to think about doing it first.

In an ideal repl-driven world you could write the test in the repl entirely and commit it to disk once you're ready.

Re:On Repl-Driven Programming by anentropic on Sunday January 03, 2021 @11:28AM (#25622724)
I find ipython + ipdb super useful in this regard

But AFAIK neither provide the feature described in the article where you can continue running after an unhandled exception.

Re:On Repl-Driven Programming by jmuhlich on Sunday January 03, 2021 @01:48PM (#25623967)
True, but running the %debug magic command in IPython immediately after an unhandled exception drops you into the debugger at the point of the raised exception, complete with the full interpreter state including the stack. It doesn’t permit edit-and-continue but you can still evaluate expressions (including calling any function) to explore what went wrong without having to recreate the situation inside an explicit pdb session.