News for hackers. Stuff that matters.
Re:What makes a good REPL? by hamandcheese on Sunday August 27, 2017 @07:39PM (#15113447)
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.
Re:What makes a good REPL? by tikhonj on Sunday August 27, 2017 @08:33PM (#15113639)
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? by Zak on Sunday August 27, 2017 @11:30PM (#15114240)
> If anything, you could always have a dedicated interpreter for interactive work

CMUCL does that. There's an interpreter that's used for the REPL and optionally for loading files on the fly, and an optimizing AOT compiler.

SBCL drops the interpreter and just runs the compiler with settings that make it reasonably fast for interactive use as I recall. Clojure, too just uses the compiler interactively and not a separate interpreter.

Re:What makes a good REPL? by mamcx on Monday August 28, 2017 @11:52AM (#15117420)
I wonder how do that. I'm building a language that truly will benefit for a REPL (is for database development) but also do it compiled simplified other things.

Is done on .NET/F#. I wonder how architect the thing so I can have a good repl yet compiled... but how?

Re:What makes a good REPL? by Zak on Monday August 28, 2017 @12:35PM (#15117880)
Since more than a few language implementations already do things like that, I'm inclined to say that's more or less a solved problem.
Re:What makes a good REPL? by mamcx on Tuesday August 29, 2017 @12:46PM (#15125595)
Yeah, but I have not find a resource that explain how is done.
Re:What makes a good REPL? by Zak on Tuesday August 29, 2017 @08:40PM (#15128820)
I think is probably an RTFS sort of topic, as there may not be a manual.
Re:What makes a good REPL? by mamcx on Wednesday August 30, 2017 @01:00PM (#15133813)
RTFS? What this mean?

Is like "some inside knowledge" but undocumented?

Re:What makes a good REPL? by dllthomas on Wednesday August 30, 2017 @03:52PM (#15135383)
"Read The [Friendly] Source [code]"

For the same concept, I prefer "UTSL"

Re:What makes a good REPL? by bernadus_edwin on Monday August 28, 2017 @12:24PM (#15117752)
I hope jetbrain will do something magic on repl
Re:What makes a good REPL? by gfody on Sunday August 27, 2017 @08:35PM (#15113647)
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? by abhirag on Sunday August 27, 2017 @08:50PM (#15113704)
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...)
Re:What makes a good REPL? by mhluongo on Sunday August 27, 2017 @07:44PM (#15113466)
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
Re:What makes a good REPL? by dllthomas on Sunday August 27, 2017 @08:47PM (#15113698)
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? by kccqzy on Sunday August 27, 2017 @09:20PM (#15113825)
Yes for (3)! I just plainly hate data types whose Show instances aren't just Haskell syntax. They usually try to add some pretty printing but that just ends such hurting copy-pasting from the REPL to the editor.
Re:What makes a good REPL? by taeric on Sunday August 27, 2017 @07:46PM (#15113473)
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.

Re:What makes a good REPL? by mhluongo on Sunday August 27, 2017 @09:54PM (#15113946)
Some of us still do in Clojure land for run-time debugging, though skipping the crazy state mutation stuff I've seen in eg CL.
Re:What makes a good REPL? by pjmlp on Monday August 28, 2017 @02:21AM (#15114740)
Java 9 is also bringing one.
Re:What makes a good REPL? by taeric on Monday August 28, 2017 @12:15PM (#15117636)
I'm curious what makes this superior to Beanshell. Or any other style of REPL that you could do on the JVM.

Not against the idea, per se, but it seems hardly new ground. And unlikely to be nearly as powerful as a REPL in CL. (Though, again, few things are. Not sure that any are, to be honest.)

Re:What makes a good REPL? by pjmlp on Monday August 28, 2017 @03:48PM (#15119497)
Well, Beanshell is dead, last update was on 2005.

Then there is a big advantage on having it as standard tool, instead of something done by third parties.

Re:What makes a good REPL? by taeric on Monday August 28, 2017 @04:14PM (#15119701)
My question in that vein is more of "why will this succeed, where beanshell failed?"

That is, I had REPL style environments for java a long time ago. And literally nobody used it. I can see arguments for having the REPL being in actual Java instead of a shell subset. But, Java has a long way to go from bootstrapping something in a repl and automatically saving it to something that will work as a normal entry point. (Though, again, even JRebel has existed for a long time now.)

Re:What makes a good REPL? by ced on Sunday August 27, 2017 @08:36PM (#15113652)
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? by markc on Sunday August 27, 2017 @08:43PM (#15113679)
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? by slaymaker1907 on Sunday August 27, 2017 @07:51PM (#15113494)
Java is getting one with the upcoming Java 9 release.
Re:What makes a good REPL? by vorg on Monday August 28, 2017 @01:34AM (#15114603)
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? by rockostrich on Sunday August 27, 2017 @08:40PM (#15113665)
Scala's REPL is fine. It has a useful paste mode as well.
Re:What makes a good REPL? by abhirag on Sunday August 27, 2017 @07:57PM (#15113520)
C# and F# do too.
Re:What makes a good REPL? by alphaalpha101 on Sunday August 27, 2017 @08:33PM (#15113634)
They aren't really REPLs. A REPL isn't just a prompt that you can put code into.
Re:What makes a good REPL? by rockostrich on Sunday August 27, 2017 @08:41PM (#15113673)
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? by alphaalpha101 on Sunday August 27, 2017 @10:53PM (#15114140)
If you want to be literal about it then sure, it just means read-eval-print loop. But I think that's akin to saying that a functional programming language is a language that has functions in it.

EDIT: To be clear, what I'm saying is that when people say 'I really love using Common Lisp because it has a REPL' they aren't saying 'I really love using Common Lisp because it has a prompt I can write raw strings of code into that executes that code and has no other features'. That's not a lovable feature.

People love Lisp REPLs because there's much more to them than that. In Lisp, the REPL is more like GDB than it is like Python's REPL.

Not really sure why the reaction to my comments here is so viscerally negative. Very few terms that we use are wholly literal. REPL isn't literal either.

Re:What makes a good REPL? by rockostrich on Monday August 28, 2017 @10:26AM (#15116712)
Sorry if my comment with the definition of REPL seemed "viscerally negative". I understand that a good REPL has more features that just the bare bones, but you said that programs that read an input, evaluated it, and then printed the result aren't REPLs. You should've said that they aren't good or useful REPLs.

Your argument is the equivalent of saying notepad isn't a text editor because you can't edit multiple lines at once or highlight syntax. Those are features that good text editors have, but it does not mean notepad is not a text editor.

Re:What makes a good REPL? by alphaalpha101 on Monday August 28, 2017 @06:41PM (#15120741)
They aren't really REPLs.

>Your argument is the equivalent of saying notepad isn't a text editor because you can't edit multiple lines at once or highlight syntax.

No it's the equivalent of saying that not even programme that can possibly, technically edit a text file is a text editor.

Python's shell thing is not a REPL.

Re:What makes a good REPL? by lispm on Sunday August 27, 2017 @09:20PM (#15113824)
A 'command line interface', for example for bash, does the same. What is the difference to a REPL? Is it just another name for the same concept or are there differences? What do you think?
Re:What makes a good REPL? by Vendan on Sunday August 27, 2017 @10:14PM (#15114019)
Yes, it's technically a REPL, just as bash is a scripting language.
Re:What makes a good REPL? by junke on Monday August 28, 2017 @05:03AM (#15115314)
It is a subtyping relationship. Bash's command line is a (minimalistic) REPL, but not all REPL are like Bash's command line. In most contexts, talking about REPLs is implicitly talking about REPLs that do more than just read, eval and print, however illogical that may sound.

Note that few languages actually define READ in a user-friendly way (since python 2.6 you have the ast package, Bash's "read" returns strings).

Re:What makes a good REPL? by jlarocco on Sunday August 27, 2017 @10:25PM (#15114052)
Compilation and a REPL are orthogonal concepts.

Lots of Common Lisp systems have very good REPLs and compile to machine code. A popular example is SBCL.

Re:What makes a good REPL? by stevedonovan on Monday August 28, 2017 @09:54AM (#15116508)
Anything can have a REPL - I did one for C++ called UnderC. Unfortunately, a technological dead end and some of the worst Bison on the planet. But it was surprisingly pleasant to use C++ in a interactive way and I wrote a C++ book working from the idea that people can learn to program better in such a conversational context. Required some interesting flexibility in the usual grammar.
Re:What makes a good REPL? by valw on Monday August 28, 2017 @03:50AM (#15115055)
The compiled or interpreted nature of a language (or its runtime) is a fuzzy concept at best (Java is interpreted on the JVM in the sense that it emits bytecode that is interpreted by the JVM; the main implementation of Clojure JVM compiles Clojure to Java bytecode that eventually gets interpreted). The notion you're looking for is probably that of incremental compilation / running.