Beyond Bash: Shell scripting in a typed, OO language
docs.google.com
docs.google.com
The author misunderstands how important this is: https://docs.google.com/presentation/d/11vZzXCfAA0aOFAuHA0nA...
The author has created a radically "better" shell language which is twice as verbose as bash. In the space of human-computer interaction where shell languages lie, this is tantamount to total failure.
The worst parts of shell are the flow control structures (if/else...). If only we could improve this without throwing out the entire system. Else we will lose the benefits of the ultra-terse and completely decentralized "language" that is unix shell.
However, there is some non-zero amount of verbosity that would be worth trading for better control flow, composability, data structures, etc. As long as you can do simple operations and pipes with the same syntax
| grep foo
cp * path/
rm -rf
it's ok if some operations are more verbose in exchange for that.Programmers don't live in bash, and deal with the pain points of switching between bash and an actual programming language on a regular basis. I know I'm there. A change that sometimes is more verbose but lets you do more things in shell would still have benefits.
You might not win over the people who are bash experts, but you could still produce a better tool for many people.
I don't agree control structures are a major problem. There are subtle differences between correct and incorrect expressions, and they are not checked at "compile" time.
One should be able to also write a debugger that can switch between these modes in real-time.
"Shell languages are defined by their terseness."
It is common to see people put a layer of verbosity on top of the Bourne shell (or system(3)) to make "a new shell".
It is also very common to see people put a layer of abstraction on top of a large, verbose scripting language and claim the result to be a new, "terse" language (with all the power of the shell).
But what I like about the Bourne shell is that it is built from only C. And it does not add too much verbosity. It is, as you say, defined by its terseness.
There is also terseness in the roff-like typesetting languages, assembly languages, FORTH, k/q, etc.
Compared to k/q, sh is verbose.
For me, verbosity means loss of power and loss of time.
I am glad there are terse languages.
They may never again be popular but I think they will always exist.
"The worst parts of the shell are the flow control structures..."
For some reason I dislike if/then/else. Instead I make heavy use return values, ||, test(1) and case/esac.
I always wished Bourne's shell (cf. Joy's C shell) made use of more C operators. There's a file called arith_lex.l in the Almquist sh source but these operators are not used in the sh language.
I would switch to the Plan 9 shell but Bourne sh remains more useful due to its ubiquity.
.. [0]: http://amoffat.github.io/sh/
I can't think of any environment where python would not be available. You can even ship sh.py as a single-file dependency along with your script, so `import cp from sh` will work as expected.
I use scheme to write most of my system stuff (most revently a custom automounter for my raspberry Pi) and thought it would have been a nice project. You could probably go macro galore and make it quite comfortable to do piping and integrate the regular system utilities in the language.
Still in early development, but very useful.
[0] http://www.haskellforall.com/2015/01/use-haskell-for-shell-s...
https://twitter.com/myatlyuka/status/577625111575969792
At the same time, Typesafe is apparently being rename Reactive Banana, which is more evidence of the increased Haskell focus within the community
https://www.reddit.com/r/scala/comments/36ho4u/breaking_type...
EDIT: found a better slide for Hascalator
The next evolution of shell is going to be something different. Something that doesn't depend on an antiquated TTY protocol, something that can display images and other constructs more complex that text, and more importantly something that allows the user to accumulate commands instead of typing the same thing over and over again.
Maybe something like ipython/jupyter
The original article is really about languages, and I think that even with the best interface in the world, we want a better language.
Any sort of shell programming is going to be full of side-effects. No matter how strict the language, building the script will still involve trying on the target system, maybe accumulating shell commands in a script, and then have these long full cycles where the script is tested on a fresh system to make sure it's still working. This is happening every time I do any sort of sysadmin-type of stuff. Even in ansible, chef, docker, ...
To escape that something deeper needs to be changed.
1. Dynamic scoping
2. Squashing lists of size 0 to nulls and
size 1 to single elements when they come out of pipes.
3. Incomprehensible API for XML handling.
On the other hand, when a Powershell program starts getting too big, it's pretty trivial to port parts of it to one of the other .NET languages.If you think Scala has a better API for XML handling then you're in for a surprise...
But I think it's not Bash vs Ammonite, it's more accurately (Alternatives to Bash) vs (The Ammonite alternative to Bash).
I've never worked in an environment that uses sh for large systems. My use is just my daily conversation with my OS and file system. I say things on the command line. Sometimes I say certain things in sequence often enough that I collect them into personal "jargon" scripts of two to twenty lines of Bash. For anything larger I generally use Python.
My dividing line between Bash and Python (or any similar language) is conversation vs contract. A conversation is relatively informal. Anything larger requires negotiation and agreement by parties (me and the OS) using technically understood formal language (to strain the metaphor).
I think Ammonite is more like the contract than the conversation, but maybe not as much as Python.