Live data from Hacker News

A Lisp REPL as my main shell

ambrevar.xyz

11–20 of 31 posts

Re: A Lisp REPL as my main shell

#11

I wonder what people think about Ammonite ( https://ammonite.io/ )? It's not Lisp but Scala so may not be the authors language of choice however it can be used as a Shell: https://ammonite.io/#Ammonite-Shell I am personally using it and compared to a classical shell like Bash it's really nice for more structured data related tasks (exploring some API, checking some data, creating a bunch of PRs at once, ...). It also…

Looks almost exactly like PowerShell in syntax but I suppose its even more powerful given lisp heritage.

Its hard to beat PowerShell tho given its integrated in infinite number of tools on Windows platform and growing number on Linux.

Re: A Lisp REPL as my main shell

#12
>Terminals have no reason to continue to be used in my opinion. Note that this does not mean we shouldn’t use “textual” interfaces, quite the opposite: textual data is a bliss to manipulate. But we can very well manipulate text, along with other types of data, in something other than a terminal, that is faster, prettier, more powerful. (Graphical Emacs is one such example.)

I have recently switched to Jupyter's qtconsole for my REPL needs - for me, it hits the sweet spot of supporting rich media and interaction without the overhead of running a full web browser stack. I could see it becoming the basis for a next-gen terminal.

Re: A Lisp REPL as my main shell

#13

I wonder what people think about Ammonite ( https://ammonite.io/ )? It's not Lisp but Scala so may not be the authors language of choice however it can be used as a Shell: https://ammonite.io/#Ammonite-Shell I am personally using it and compared to a classical shell like Bash it's really nice for more structured data related tasks (exploring some API, checking some data, creating a bunch of PRs at once, ...). It also…

PowerShell is the only mainstream shell that builds on the ideas of Lisp Machines, Xerox PARC and ETHZ workstations, naturally I am quite found of it, despite some of its quirkiness.

It does structured data, native support for extending it via .NET and native libraries and at least on Windows, can plug into OS Automation libraries.

What it misses is graphical display on the REPL.

I can easily see PowerShell Core replacing my uses of Python in what concerns Linux VMs.

Re: A Lisp REPL as my main shell

#14
post #13

I wonder what people think about Ammonite ( https://ammonite.io/ )? It's not Lisp but Scala so may not be the authors language of choice however it can be used as a Shell: https://ammonite.io/#Ammonite-Shell I am personally using it and compared to a classical shell like Bash it's really nice for more structured data related tasks (exploring some API, checking some data, creating a bunch of PRs at once, ...). It also…

PowerShell is the only mainstream shell that builds on the ideas of Lisp Machines, Xerox PARC and ETHZ workstations, naturally I am quite found of it, despite some of its quirkiness. It does structured data, native support for extending it via .NET and native libraries and at least on Windows, can plug into OS Automation libraries. What it misses is graphical display on the REPL. I can easily see PowerShell Core repl…

I think this talk actually came up in a thread on the guile mailing list about adding powershell as a guile language.

Re: A Lisp REPL as my main shell

#15
I don't get lisp. Actually I think I understand what people like about it. What I mean is that I don't know exactly how to "think in lisp". Is it like writing the AST instead of the text or describing what is needed instead of what needs to be done... I simply don't get it.

Not sure if I'm the only one though.

Re: A Lisp REPL as my main shell

#16

I don't get lisp. Actually I think I understand what people like about it. What I mean is that I don't know exactly how to "think in lisp". Is it like writing the AST instead of the text or describing what is needed instead of what needs to be done... I simply don't get it. Not sure if I'm the only one though.

What you said is true and perceptive — it is at base like writing the AST - but most of the time you’re just doing function calls with the opening paren shifted to the other side of the function name.

In other words, in Algol like languages you’re typically calling like(this) (or the dotted.equivalent(form)) and in lisp it’s (like this).

You do eventually take advantage of the fact that you’re writing an AST, when you get into macros. But that feels pretty simple once you’re used to the function syntax, since macros just manipulate the resulting structures.

What used to throw me off was the special syntax for lists - ‘(structures looking like this) - but once you get used to using the lisp structure for function calls it becomes clear why and when this kind of quoting is necessary (any time you want a list as data instead of a function call).

Re: A Lisp REPL as my main shell

#17
post #5

> Implement automatic ncurses detection to automatically start a “visual” program in a terminal, even when it’s not known in advance. Is it even possible? There are a couple of techniques: 1) Check for use of certain escape sequences in the output. 2) Check PTY terminal modes using tcgetattr, especially for raw mode I think combining (1) and (2) you could come up with some heuristics that would work 99% of the time,…

Can you switch mode once the executable's already been launched, though? It's already got its tty, so you'd presumably need to start up the ncurses-capable terminal on demand, switch it in, and play back any meaningful prior output so it's in sync. The page is dead so I can't see how they handle it, but each of those steps is potentially problematic, isn't it?

Re: A Lisp REPL as my main shell

#18
You may be forced to use Scheme as as shell when encountering an error booting GuixSD. Back in 2016, support was apparently not good for the AMD bulldozer systems I was trying to install on. The systemd alternative they used, GNU shepherd, crashed on me, and left me in a Guile REPL.

Re: A Lisp REPL as my main shell

#20
post #5

> Implement automatic ncurses detection to automatically start a “visual” program in a terminal, even when it’s not known in advance. Is it even possible? There are a couple of techniques: 1) Check for use of certain escape sequences in the output. 2) Check PTY terminal modes using tcgetattr, especially for raw mode I think combining (1) and (2) you could come up with some heuristics that would work 99% of the time,…

Can you switch mode once the executable's already been launched, though? It's already got its tty, so you'd presumably need to start up the ncurses-capable terminal on demand, switch it in, and play back any meaningful prior output so it's in sync. The page is dead so I can't see how they handle it, but each of those steps is potentially problematic, isn't it?

> Can you switch mode once the executable's already been launched, though?

Yes, apps can change terminal mode at any time. The solution the author went with is to have a list of "visual program" names, and when a visual program name is detected, launch it in an external terminal (xterm or Emacs vterm). That is making no attempt to handle mode switches during program execution, it is making a permanent decision before the program starts based on its name.

I think the solution here is to have a visual terminal "widget" that can be embedded into the graphical REPL, and the REPL constantly monitors the output and terminal mode of the subprocess, and when the REPL detects initiation of visual mode, start an embedded visual terminal widget, and then stop the visual terminal widget when it detects visual mode is completed.

On Linux, it is possible for the pty master to be immediately notified of any mode changes in the slave [0], using packet mode and EXTPROC. I don't think that facility exists in most other operating systems.

[0] https://stackoverflow.com/questions/21641754/when-pty-pseudo...

Post reply on HN