Hacker News new | ask | show | jobs
by yoodenvranx 3225 days ago
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.
7 comments

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...

Most Lisp modes for Emacs have an eval-sexpr-at-point command which allows you to send the current sexpr to the REPL. This is in SLIME for CL but even the most basic Scheme mode has it as well.
Clojure's Emacs REPL also has this; it's strange that the article does not mention it, but talks about copying back and forth between REPL and suorce, which I consider a antipattern and really ugly workflow.
Emacs can do this with Ruby, Python... Hell, you can get it to eval buffer, region, line with anything that'll accept input and return a useful output.

The ease at which one can get any language (or I/O machine) to play along with this workflow in Emacs is astonishing.

You seem to be using SublimeText, check out SublimeREPL extension[https://github.com/wuub/SublimeREPL/blob/master/README.md]. Once setup you'll be able to evaluate code blocks in a running REPL :) Also, Emacs modes of most languages with REPLs will have this functionality inbuilt.
Matlab's REPL experience is great. It satisfies almost all of the "what makes a good REPL" and "what makes a programming language REPL-friendly" criteria in the article. Having a full featured plotting library available to inspect intermediate values when debugging is amazing.
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

I have never used a Lisp Machine so forgive my naivety but I saw the demo and you seem to be referring to the ability of displaying images inline in a buffer. Emacs can definitely do that, I have used Emacs IPython Notebook[1] which is a REPL supporting this. I could fire up a jupyter notebook and use pillow[2] to recreate the image manipulation part of the demo.

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

That is partially what I was referring to.

The other part, which might not be visible on that video is the integration of debugger into the REPL, and the ability to redo a piece of code after breaking into the debugger and fixing it.

So you can do something like, REPL => error (ask to start debugger) => track down and fix error => restart error expression => finish the execution of the original REPL expression with the respective result.

The only debugging experience I find enjoyable in Emacs is debugging Clojure using cider[1] and I think it comes close to what you are describing but I think you might already be aware of that :)

[1] -- (https://github.com/clojure-emacs/cider/blob/master/doc/debug...)

SLIME doesn't give you this?
I don't know, back when I cared about Lisp development on Emacs, SLIME wasn't a thing, as you might understand from my XEmacs reference.
What do you mean with "picking them all up?"
They mean the learning curve is steep.
A "steep learning curve" actually means that the amount learnt grows rapidly over time. It's odd how this basically obvious conceptualization has had its meaning inverted in popular usage.
This is one of my pet peeves, as well. Though I have moved on. Colloquially, it is clear how folks take that saying. Just transpose the chart if it helps you think about it.

That is, it may have originated with that meaning. But it is far from unique in having the general meaning shifted with use.

Ah, fair enough. The nice thing is most repl's have the same bindings as each other. So, some basic drills can get you up to speed.
Lisp buffers? Smalltalk workspaces? Is this capability any different from those?
I guess Mathematica has the most advanced interface in that respect. That's what inspired all the other repls like Jupyter.