Live data from Hacker News

What makes a good REPL?

vvvvalvalval.github.io

21–30 of 177 posts

Re: What makes a good REPL?

#21

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

I don't think there's anything fundamental about a compiled language that prevents it from having a REPL. (If anything, you could always have a dedicated interpreter for interactive work—"compiled" and "interpreted" are functions of the implementation, no the language.)

In practice the compiled languages I've used extensively (OCaml and Haskell) do have REPLs, but ones that aren't nearly as powerful as some other languages. I'm not sure exactly why it's the case, but I certainly don't think it's impossible for them to have good REPLs. My guess is that there are some properties of the languages that make a good REPL a bit more difficult to implement, and there simply hasn't been enough community investment to overcome that.

I wish there was because I basically live in GHCi (Haskell's REPL) and sorely wish for a few core improvements like hot loading updated code when possible.

Re: What makes a good REPL?

#22

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

I think the compiled language analog of a REPL is something like LINQPad for C# where you code in the top pane, highlight a snippet to execute, and get the results in the bottom pane. Combined with the more functional-style language features it's very conducive to layering on complexity and analyzing code where you can execute inner layers to see what they do.

Re: What makes a good REPL?

#23
post #7

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

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

Julia has had a good REPL since its inception, (along with the awesome Jupyter notebooks). It also allows live code replacement (eg. Revise.jl).

Re: What makes a good REPL?

#24
post #7

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

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

Scala's REPL is fine. It has a useful paste mode as well.

Re: What makes a good REPL?

#25
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

They aren't really REPLs. A REPL isn't just a prompt that you can put code into.

REPL stands for read-eval-print loop. So yes, it is just a prompt that you can put code into that will print a result.

Re: What makes a good REPL?

#26
post #7

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

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

The language used as an example in the article (and one that fulfills its criteria for a good REPL) is Clojure - which is compiled.

Re: What makes a good REPL?

#27

Quokka adds a nice repl like experience for JavaScript/typescript to various editors. I'm a fan of their products! Hydrogen is quite nice for python repl development in atom. Hydrogen connected to a remote kernel plus a script to synchronize files to a remote server replaces writing code in Jupyter notebooks for me (I just can't enjoy editing code in a browser ...)

Hydrogen seems nice, I also occasionally get tired of the default jupyter notebook interface and use Emacs[1] to edit my notebooks, this way I can have all the niceties of jupyter notebooks without working in the browser :D

[1] -- (https://github.com/millejoh/emacs-ipython-notebook/blob/mast...)

Re: What makes a good REPL?

#28
post #7

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

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

Haskell has one - called GHCi. By these criteria:

1) You can define new functions (and values, and types, type classes, instances, etc). You can "redefine" these things only insofar as you can shadow them.

2) I'm not sure whether they mean the ability to persist your state to disk and restore it (which GHCi lacks), the ability to refer to previous results (in GHCi, the previous result is called `it`), or just the ability to bind variables (of course you can do this in GHCi).

3) Usually "Show" instances are meant to be embeddable in code. Sometimes they need a little massaging. Sometimes they're just broken, from this POV. Sometimes they're just broken, period. But it holds for a lot of values.

4) You can run GHCi in the context of your project (see cabal repl and stack repl commands).

5) GHCi very much fails at this - no way to add anything to a module, so far as I'm aware.

6) GHCi more-or-less lacks this kind of functionality. You could run your server's "main" function from the REPL, but there's not much you can do to it.

7) :reload

8) There's an increasing amount of such tooling; only some of it has any particular tie to the REPL, per se.

Re: What makes a good REPL?

#29
post #22

There's a lot of excitement about compiled languages lately, and many seem to wonder if interpreted languages are dying. Unfortunately I don't see the value of a good REPL brought up in those conversations very often.

I think the compiled language analog of a REPL is something like LINQPad for C# where you code in the top pane, highlight a snippet to execute, and get the results in the bottom pane. Combined with the more functional-style language features it's very conducive to layering on complexity and analyzing code where you can execute inner layers to see what they do.

Although LINQpad is awesome, the newer versions of Visual Studio have a C# REPL built in -- (https://github.com/dotnet/roslyn/wiki/C%23-Interactive-Walkt...)
Post reply on HN