Live data from Hacker News

What makes a good REPL?

vvvvalvalval.github.io

51–60 of 177 posts

Re: What makes a good REPL?

#51
"Finally, not all programs need be fully automated - sometimes the middle ground between manual and automated is exactly what you want. For instance, a REPL is a great environment to run ad hoc queries to your database, or perform ad hoc data analysis, while leveraging all of the automated code you have already written for your project"

This is exactly why I love Python. My Django webapp gets features (DB reports, external API pushes, etc) added as the client's budget allows, and before they are I'll often do them manually. Given that the UI for a new feature is usually the most work, it's been working well.

So the process usually goes: REPL/Django shell -> Django management command -> End-user facing feature. I'll grab what I did the first time in the Django shell, and put it into model logic plus a tentative management command. Then the next time I have to do the task I'll make sure the command works properly. And then when the budget allows I'll add access via the UI.

Ninja edit: I forgot to mention that `import ipdb; ipdb.set_trace()` is invaluable to get to the point in the HTTP response code where you can start adding new stuff or diagnose errors directly.

Re: What makes a good REPL?

#53

I would also add hot loading, aka the ability to change your code and get to the same point in the execution of the code.

I can't live without auto reloading in ipython. It's not perfect, but I work in a space where I need to load a lot of state before I can do anything meaningful. Being able to change to code inside running objects and maintaining all that state in memory is an absolute god send.

Re: What makes a good REPL?

#54
post #33

Matlab has a nice sort-of-repl feature which I miss in every other language: you can separate the code in a file into several blocks and then execute the current block (the one with which contained the cursor) with ctrl+enter. With this feature you still have the full text editing capabilities but you also have a flexibility you get from a repl.

Jupyter[1] lifted this feature from Matlab & made it work with any kernel. [1]: http://jupyter-notebook.readthedocs.io/en/latest/examples/No...

I believe it was inspired by Mathematica which created the concept of notebooks with cells backed by a kernel in 1988:

https://en.wikipedia.org/wiki/Wolfram_Mathematica#The_Notebo...

Re: What makes a good REPL?

#55

"Finally, not all programs need be fully automated - sometimes the middle ground between manual and automated is exactly what you want. For instance, a REPL is a great environment to run ad hoc queries to your database, or perform ad hoc data analysis, while leveraging all of the automated code you have already written for your project" This is exactly why I love Python. My Django webapp gets features (DB reports, ex…

I've dabbed in elixir and clojure for some time now and the ability to gain a REPL into a live system opens many opportunities for live debugging and introspection. It's a great tool when dealing with unknown states and bugs in production.

Re: What makes a good REPL?

#56
post #7

Earlier quoted context omitted.

I like a good interpreted language as much as the next guy, but there are REPLs for compiled languages. Pretty sure Scala has one and maybe Haskell

Java is getting one with the upcoming Java 9 release.

I doubt many programmers already using Jython, Beanshell, Apache Groovy, Xtend, Rhino, or Nashorn will change to the Java 9 JShell. I switched from Groovy to Clojure for scripty stuff a few years ago, mainly for the macros. A well-placed macro can avoid a lot of clutter in repetitive testing -- a far better solution than some heavy-weight testing framework.

Re: What makes a good REPL?

#57
post #47

With fast compiling languages a unit test is not for off from being a REPL. In Java I use JUnit as a REPL. Actually I prefer unit tests over a REPL the same reason I prefer bash scripts over one liners or SQL scripts instead of typing into the interpreter... I don't like the ephemeral nature of REPLs. Also with true REPLs unlike the debug unit test approach I mention with Java you really need the language to be dynam…

REPLs are not ephemeral on Common Lisp environments.

There are/were true REPLs with static languages, Mesa/Cedar and Oberon are two examples that come to mind.

On Mesa/Cedar's paper they refer that they wanted to provide the same experience as their Smalltalk and Interlisp-D environments.

On Oberon's case, it required just recompiling/reloading a specific module, which given Oberon's compile speed, was pretty quick.

.NET has now a REPL, which coupled with Edit-and-Continue (when it works) is also quite good.

I used to use Jython/Groovy as my Java REPL, now just have to wait for the Java 9 release.

Re: What makes a good REPL?

#58
post #5

Matlab has a nice sort-of-repl feature which I miss in every other language: you can separate the code in a file into several blocks and then execute the current block (the one with which contained the cursor) with ctrl+enter. With this feature you still have the full text editing capabilities but you also have a flexibility you get from a repl.

Lisp + Emacs + SLIME: miss no longer. Picking them all up is a tall order though.

Emacs suffers from not being like Lisp machines REPL, meaning lacking graphical display on buffers.

If I remember correctly, XEmacs used to support it (which was my favorite fork), but it seems to have faded away.

For example, try to achieve this demo on Emacs.

https://www.youtube.com/watch?v=o4-YnLpLgtk

Re: What makes a good REPL?

#59
post #8
post #7

Earlier quoted context omitted.

I like a good interpreted language as much as the next guy, but there are REPLs for compiled languages. Pretty sure Scala has one and maybe Haskell

Though, they are lacking the magic of a REPL in CL. Hotspot replacement in JVM languages is neat compared to the magic of redefinitions in CL. And it seems nobody ever tries hooking a REPL up to a running system anymore.

Java 9 is also bringing one.

Re: What makes a good REPL?

#60
post #47

With fast compiling languages a unit test is not for off from being a REPL. In Java I use JUnit as a REPL. Actually I prefer unit tests over a REPL the same reason I prefer bash scripts over one liners or SQL scripts instead of typing into the interpreter... I don't like the ephemeral nature of REPLs. Also with true REPLs unlike the debug unit test approach I mention with Java you really need the language to be dynam…

Java is getting a REPL though. I believe it is part of Java 9 ;).
Post reply on HN