Live data from Hacker News

On Repl-Driven Programming

mikelevins.github.io

81–90 of 210 posts

Re: On Repl-Driven Programming

#81
How is this different from, say, programming in Python and being forced to drop into a debugger whenever there is an error? The debugger also lets you see everything in the stack, modify definitions, etc.

MATLAB and R both have options to drop you into a debugger if there is an error. Not sure if Python's debugger can do this, but other than that, this style of programming is perfectly doable outside of Lisp and Smalltalk.

Re: On Repl-Driven Programming

#82
post #78
post #58

For anyone who would like to see what REPL-driven programming looks like in practice, take a look at this video here: https://vimeo.com/230220635 The author uses the Clojure REPL to walk through the process of developing some non-trivial functionality (calling an API and parsing the results). It’s a good intro to what it looks like to interactively build a program while it’s running. Personally, I’ve found that havin…

Interesting. I do the same thing in Elixir where I'll attach an iex session to a Phoenix application so I can interrogate modules and APIs as I'm building them out. I'm slightly disappointed that it's already something I do day to day. I had hoped that the power of the REPL wasn't overstated.

I think just because someone is able to do something similar in another language doesn’t mean that the power of a fully integrated REPL is overstated.

Most developers are using languages where this sort of thing isn’t possible, and for them, experiencing a REPL driven development flow can be an eye opening experience (even if it’s just to add it to their tool box along side more common approaches like attaching debuggers and using TDD to shorten the development feedback loop).

I don’t know enough about Elixir to understand how your approach is the same/different than using something like a REPL with Clojure, but I did come across a pretty interesting discussion on the topic:

https://elixirforum.com/t/what-do-you-all-think-of-clojures-...

TL;DR - you can accomplish something similar with Elixir, but the underlying technical details are different.

Re: On Repl-Driven Programming

#83

Having used Clojure and Common Lisp professionally, I think advocates for REPL driven programming universally overstate the utility of a first rate REPL. Yes, it’s nicer than Python’s. Yes, it’s convenient. No, I never ended up doing my development in the REPL first . Why? Because editing mistakes in a REPL usually sucks, because a REPL is not a text editor. What I ended up using heavily was REPL to file integration,…

> What I ended up using heavily was REPL to file integration, which gave me the ability to write a function normally, evaluate it in the attached REPL session, and then play around with it in the REPL

When I do REPL driven development in Clojure, that's exactly what I do and that's what other folks that I know mean by REPL driven development (in Clojure): define types, functions and variables in a source file, often in a (comment) form, eval them one by one, and copy the code out of the (comment) form when it's stable enough. I wouldn't type code directly into the REPL; that's not a pleasant experience in Clojure - but might be pleasant in Common Lisp or Smalltalk for all I know. The process that I and others use in Clojure most definitely differs from the process that the OP describes and I lack enough familiarity with Common Lisp to know if the process is more pleasant in that language. I assume it is and I must make time to learn Common Lisp properly some day.

Re: On Repl-Driven Programming

#84
post #18

Is there a modern non-Smalltalk, non-Lisp (or its derivatives) non functional imperative programming language that supports a "real repl" that the author is talking about? I don't know if that kind of environment is for me but I'd love to give it a spin. I have never found the REPL (the Python/Ruby REPL which is not a "real repl" according to this article) to be that useful beyond quickly playing with API of a librar…

Bash?

Re: On Repl-Driven Programming

#85
My concept of a "REPL" is mostly defined by emacs. You would have a buffer with a code file, with an active jupyter kernel with the correct dependencies loaded in it. Then one would send any active region with `C-c C-c` and get timely feedback.

With this mode https://github.com/nnicandro/emacs-jupyter one can connect to a jupyter kernel running locally or remote (would mostly prefer SSH port forwarding or kubectl port-forward the remote jupyter server). It makes life so much easier to interact with cloud environment (e.g. spark).

Re: On Repl-Driven Programming

#86
Author describes a nice feature, but that’s not what makes repl-driven development tick for me. Repl really shines when editor integrates with it - send a form to evaluate, instantly get result back into the editor, eval a form and replace it with the value received, define and redefine the environment on the fly, get instant feedback if your code works without having to drop into shell and run some test command, micro-tests and usage examples that you can actually run inside editor to see how they work.

You can get similar integration with ruby and python, but there’s way more friction because that kind of development is not the blessed way and so nobody bothers to make it work.

Re: On Repl-Driven Programming

#87
post #5

Earlier quoted context omitted.

You can also add breakpoints which automatically occurs when exceptions are raised. Which is similar to the breakloop functionality mentioned in the article.

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.

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.

Re: On Repl-Driven Programming

#88

He's right to emphasize the properties of the systems that support interactive development with a long-running image. In Common Lisp, the difference between defvar and defparameter is a simple example. Traditional Smalltalk systems only supported image-based development. But I always preferred the moderate approach exemplified by most Lisp systems where the source code isn't overly entangled with the image state. As…

You misunderstand me. By "repl-drive programming" I do not mean programming that is fixated on the "command-line repl". On the contrary, what I'm talking about has much more in common with what you describe as "far more productive". It's not about a particular shell or window or buffer; it's about a runtime environment that is designed to support writing software by building and changing it as it runs.

By "repl", I do not mean the window or the buffer or the shell program. I mean the loop of: read an expression, evaluate it, and present the results, in the context of a runtime that is designed to comprehensively support it.

Moreover, you can have all of the tools that you listed and still not be working with a properly-designed repl-driven environment. For example, I built a 3D interactive environment on the JVM that worked quite well--it launched into the 3D environment ns no more than a second or two, and could build whole procedurally-generated scenes in a few seconds. It supported networked multiuser interactions. I could start it from a repl and dynamically alter scenes and objects and their behavior in the environment by talking to them.

It still wasn't a proper repl-driven environment because the underlying runtime could not correctly handle dynamic redefinition of classes and methods. That meant that if I decided that I needed to change a representation or something, I had to kill the environment and rebuild it. It meant that there was always a gratuitous barrier that I might run into at any moment. It meant that some abitrary set of things I was working on was always on the other side of that barrier.

Contrast that to working with, for example, SK8, where I could redefine absolutely everything in the environment (including, for example, the system-level procedures used to draw window frames) without ever restarting the code that was under development.

Re: On Repl-Driven Programming

#89

I think the best modern example is ObservableHQ [1]. I took a screen shot yesterday when I found myself interleaving runtime, TDD, IDE, debugger and partial recompilation in one window. It blew my mind. I have never experienced such a productive programming environment. https://twitter.com/tomlarkworthy/status/1345321532650905601... For there I can change variable at runtime. Change the implementation and have the te…

Thanks for pointing it out. The site went on my reading list.

Re: On Repl-Driven Programming

#90

Nobody has mentioned low-level programming in a REPL. Not as common to be sure. Forth works this way and even has REPL Assembly Language. It's been there for over 40 years. Testing Forth and ASM code snippets in the REPL before committing to them helps eliminate those nasty assumptions about what "should" work.

Agreed, FORTH is repl-driven in the sense I mean. The main difference from Lisp and Smalltalk systems is that FORTH environments are, generally speaking, more spartan.

In the late 1980s I had a group of friends at Apple that included Smalltalk, Lisp, and FORTH programmers. We certainly found plenty of things to admire and attempt to steal from one another, and everyone accepted the basic goodness of building systems by engaging in conversation with them as they run.

Lisp and Smalltalk cross-pollenated each other more than each did with FORTH, but maybe Slava Pestov's Factor is a glimpse of what you get if FORTH is more in the mix.

Post reply on HN