News for hackers. Stuff that matters.
Re:Z.lua – A new cd command that navigates faster by learnin... by ariabuckles on Monday February 04, 2019 @01:33PM (#19079155)
We can definitely evolve shells more.

Most shells offer a convenient syntax around a lot of (fantastic) utilities that often mirror C libraries (notably posix). When we were working in C, having our shell mirror parts of that at times while being a very dynamic language at other times sounds great.

But we have a much more varied landscape of language and library options now, and many developers haven’t ever used C or posix.

So my thought is: what if we had a shell that was designed to interop with JS (or python, or ideally a language the user knows well), instead of C/posix. What if, instead of having to remember bash’s for loop syntax (or xargs), you could just write .map() and iterate over lines/execute commands that way?

Re:Z.lua – A new cd command that navigates faster by learnin... by evanmoran on Monday February 04, 2019 @01:51PM (#19079376)
Totally agree with this. We need to create shells based popular languages so language syntax stops being a barrier to entry for new people. How many times do we search for "if statement bash" or "function bash" because the if and function syntax isn't modern and isn't easy to remember?

Transforming the shell is a great opportunity for a new project, and as you said should probably should be done in Python or JS. Lua is a good option as well for its elegance, though it's a bit less popular than the others.

As for Z.lua, this is an interesting project and I really like seeing modern languages enriching what we do every day on the command line. Very cool!

Re:Z.lua – A new cd command that navigates faster by learnin... by chubot on Monday February 04, 2019 @02:11PM (#19079596)
That's the motivation behind my Oil project:

Why Create a New Unix Shell? http://www.oilshell.org/blog/2018/01/28.html

I took a very long route to doing it though, first implementing OSH (which will run existing shell scripts, which is close to done, but slow) and then Oil (a new language, not implemented).

This is because POSIX shell/bash has a really strong network effect. zsh and fish are better in many respects, but people are locked into bash because that's what "everybody else uses".

It's analogous to how C has a really strong network effect because e.g. every kernel is written in C. So C++ became a popular language in a large part because it's compatible with C. (Though the analogy breaks down because the Oil language isn't a superset of bash, so we can break free of legacy. The project is though.)

In my mind, I think of Oil as a mix between Python and shell, with some elements of Ruby and JS (blocks, function literals, etc.)

Re:Z.lua – A new cd command that navigates faster by learnin... by ariabuckles on Monday February 04, 2019 @02:33PM (#19079823)
I love what you're doing with Oil! Looking forward to trying the interactive version in the future :)

And yes, network effects are so important—your C++ example is spot on. One recent example that comes to mind is the adoption from python2 to python3, showing just how big a barrier those network effects are to adopting something incompatible.

Re:Z.lua – A new cd command that navigates faster by learnin... by chubot on Monday February 04, 2019 @04:15PM (#19080711)
Thanks! I'm writing a blog post now about how I got the majority of bash-completion running, so I'm now using OSH myself. This is the biggest milestone in a long time!

It exposed the slowness issue though. I have a plan for that, but it's a bunch of work.

It will help me if people try it and give feedback -- I'll give details in the post.

I definitely agree about Python 2/3. I think you basically can't overestimate the amount of inertia a popular language has. I'm sure there will be patches floating around for Python 2 for a long time after the core team stops maintaining it next year.

Another example is all the compile-to-JS languages. I think TypeScript is the most popular in part because its transition path is the easiest, i.e. it's a superset of JS.

Re:Z.lua – A new cd command that navigates faster by learnin... by ariabuckles on Monday February 04, 2019 @08:35PM (#19082413)
That’s awesome! I’d love to try it; details in an upcoming blog post?
Re:Z.lua – A new cd command that navigates faster by learnin... by nijaru on Monday February 04, 2019 @06:57PM (#19081875)
how's oil going? I haven't looked into it in about a year or so, but it seemed like a cool project
Re:Z.lua – A new cd command that navigates faster by learnin... by chubot on Monday February 04, 2019 @07:58PM (#19082243)
There will be a big status update in a few days here: http://www.oilshell.org/blog/

Or you can subscribe in one of these places :)

https://www.reddit.com/r/oilshell

https://twitter.com/oilshellblog

Re:Z.lua – A new cd command that navigates faster by learnin... by saghm on Monday February 04, 2019 @02:28PM (#19079776)
> How many times do we search for "if statement bash" or "function bash" because the if and function syntax isn't modern and isn't easy to remember?

The number of times I've used a for loop in shell is roughly equal to the number of times I've had to look up how to use a for loop in shell. Relatedly, I generally switch to Ruby when my scripts get complex enough to require control flow.

Re:Z.lua – A new cd command that navigates faster by learnin... by boomlinde on Tuesday February 05, 2019 @05:38AM (#19084153)
For some tasks I find myself writing my scripts in bash with a bunch of python herefiles. Bash is pretty straight forward when it comes to text stream processing and tool integration but for anything more the herefiles are a good way to avoid figuring out bash control flow and messing with list delimiters
Re:Z.lua – A new cd command that navigates faster by learnin... by bdukic on Monday February 04, 2019 @05:12PM (#19081150)
Agreed, I always feel like there is so much great shell-related code scattered all over people's dotfiles and we could all benefit from a kind of modernization you and the parent are mentioning.

This is my attempt so solve a small personal pain point in the shell while trying to keep track of various commands: https://github.com/bonidjukic/aka

It definitely comes nothing close to the Z.lua, but the enjoyment generated from getting to write the thing which optimizes even the tiniest parts of your daily tasks is quite wonderful.

Re:Z.lua – A new cd command that navigates faster by learnin... by ksherlock on Monday February 04, 2019 @08:38PM (#19082421)
If you're using bash, there's a usable help builtin.

    help
    help if
    help function
etc.
Re:Z.lua – A new cd command that navigates faster by learnin... by ariabuckles on Monday February 04, 2019 @02:28PM (#19079768)
Oh right, I forgot lua! I love lua and would enjoy that shell (and the metaprogramming available makes it much easier to let unknown commands call programs, which I've tried once).

But I expect for adoption it'll need to be a more widely-used langauge

Re:Z.lua – A new cd command that navigates faster by learnin... by kevin_thibedeau on Monday February 04, 2019 @03:37PM (#19080386)
#!/bin/env/poplang
Re:Z.lua – A new cd command that navigates faster by learnin... by rhacker on Monday February 04, 2019 @02:01PM (#19079480)
That is the fundamental idea behind powershell. PS accesses the .NET world kinda like that. Many people love it. I would want one similar for JS and mainly fixated on the linux world (but works in Windows). Whereas PS works in Linux, I would say .NET isn't a great target for the linux audience.
Re:Z.lua – A new cd command that navigates faster by learnin... by Pxtl on Tuesday February 05, 2019 @12:05AM (#19083134)
I code a crapload of PowerShell and I've come to hate it. It's the most inconsistent language I've ever used, and the docs always bury the lede about the format of the returned object-stream, leaving me grasping to find the types and properties of everything where more text-oriented consoles would be far more wsiwyg.
Re:Z.lua – A new cd command that navigates faster by learnin... by carlmr on Tuesday February 05, 2019 @06:13AM (#19084292)
Yeah, it's a great idea but terribly executed.

They could have just used F# as the new shell language, the interpreter already exists, the syntax is clean and concise, etc.

Re:Z.lua – A new cd command that navigates faster by learnin... by johnmaguire2013 on Monday February 04, 2019 @06:59PM (#19081891)
I joked about this years ago. I'm not a Javascript fan, so really, I lamented that in a few years time, someone would make a CoffeeScript REPL[1] with built-in functions mirroring the Linux shell[2]. Call it jssh or sh.js.

Just a few days ago, I saw a shell interpreter that had a method for bouncing in and out of Python with ease.[3] I'm sure the Javascript version isn't long behind.

[1] https://coffeescript.org/#overview

[2] https://www.npmjs.com/package/shelljs

[3] https://xon.sh/tutorial.html#python-mode-vs-subprocess-mode

Re:Z.lua – A new cd command that navigates faster by learnin... by gpderetta on Tuesday February 05, 2019 @02:56AM (#19083658)
> What if, instead of having to remember bash’s for loop syntax (or xargs), you could just write .map() and iterate over lines/execute commands that way?

But you can! The dot is spelled '|' of course, and 'map' for historical reason is called 'xarg'. There is no real lambda syntax nor closures though, everything is stringly typed.

Re:Z.lua – A new cd command that navigates faster by learnin... by Gaelan on Monday February 04, 2019 @01:43PM (#19079287)
Check out xonsh. I haven’t used it but it’s supposed to be a python/bash hybrid shell.
Re:Z.lua – A new cd command that navigates faster by learnin... by pmalynin on Monday February 04, 2019 @02:11PM (#19079598)
Xonsh is good, I’ve used it for a bit. I loved customizing but in the end I found the reliance on prompt toolkit unfortunate. It’s significantly slower than fish for example. Trying to hook into how search and similar stuff works is really hard — you end up having to hook into xonsh and then into prompt toolkit, and a lot of the source feels like it was cobbled together with a bunch of libraries.

But it’s fun to use, still. I might come back to it a few versions down the road.

Re:Z.lua – A new cd command that navigates faster by learnin... by _emacsomancer_ on Monday February 04, 2019 @07:49PM (#19082200)
eshell (https://www.gnu.org/software/emacs/manual/html_mono/eshell.h...) is a bit like that, but with Lisp.
Re:Z.lua – A new cd command that navigates faster by learnin... by ninjaaron on Tuesday February 05, 2019 @05:42AM (#19084174)
You have not because you ask not.

https://xon.sh/