“Use Dumb Shell, don’t Reinvent the Wheel”
Tags: bashingbash, ngs, rant, systemadministratio
Published: 2020-03-21 09:42:19

---
title: “Use Dumb Shell, don’t Reinvent the Wheel”
published: true
date: 2020-01-04 15:05:40 UTC
tags: bashing-bash,NGS,Rant,System administratio
canonical_url: https://ilya-sher.org/2020/01/04/use-dumb-shell-dont-reinvent-the-wheel/
---

## Opening Rant

You don’t hear one developer saying “Just use Notepad” to a colleague with argumentation that goes roughly like this:

> Why are you using this horrible [Visual Studio Code](https://code.visualstudio.com)? It has built-in debugger! No!
> 
> [JetBrains](https://www.jetbrains.com) IDEs? No! They do too much! They are so into the code!
> 
> [Vim](https://www.vim.org)? [Emacs](https://www.gnu.org/software/emacs/)? Not pure enough! Who needs that stupid syntax highlighting?
> 
> **Keep text editing pure! Any semantic understanding by the text editor is undesirable, other programs should handle that. You don’t want to complicate the text editor.**

Developers are not saying that because **user experience and productivity matter**. Yet, “Use Dumb Shell” is considered to be an acceptable opinion. Is that so common that people fall on their heads so hard (alternatively, did not give it any thought)? WTF?

The solution (shell) should be as simple as possible but not simpler than possible. **Current shells are simpler than required by good user experience. Wrong trade-off.** Keeping something simple is important but not more important than the outcomes.

[![](https://ilyasherdotorg.files.wordpress.com/2020/01/too_busy_to_improve_-_performance_management_-_square_wheels-1.png?w=1024)](http://www.workcompass.com/)<figcaption><em>Source: <a href="https://www.flickr.com/photos/toddle_email_newsletters/15413603567/" rel="nofollow">https://www.flickr.com/photos/toddle_email_newsletters/15413603567/</a><br>Image is a link to <a href="http://www.workcompass.com/" rel="nofollow">http://www.workcompass.com/</a></em></figcaption>

Additional food for thought:

1. Why use a car when bicycle is so much simpler?
2. Why use electricity when fire is so much simpler?
3. Why have water in your house when a wells are so much simpler?

## Background

I was doing consulting. The usual suspects: AWS, bash, Python, [Puppet](https://ilya-sher.org/2017/06/09/please-dont-use-puppet/), Chef. Got to Terraform later. I had and I am still having subpar experiences with these tools. Anything I wanted to do, was overly burdensome, complicated and full of [pitfalls](https://github.com/terraform-providers/terraform-provider-aws/issues/3209).

Since I can’t attempt to fix everything, I picked the worst offender and started working on the alternative programming language and shell combo. The motivating opinion is that **Ops have no good programming language nor adequate shell.**

The [absence of good programming language for ops was covered in another post](https://ilya-sher.org/2017/10/10/why-i-have-no-favorite-programming-language/). In this post I will cover some of the things that are wrong with the interactive shell.

## The Shell

The dominant player is `bash`. It didn’t change much for decades: you type commands and get a dump of text on your screen. Most of the alternatives are essentially the same in this regard, for decades.

Is this because of the brilliant design? I would ask: which design? [This](https://stackoverflow.com/questions/78497/design-patterns-or-best-practices-for-shell-scripts)? Quoting:

> I wrote quite complex shell scripts and my first suggestion is “don’t”. The reason is that is fairly easy to make a small mistake that hinders your script, or even make it dangerous.

## The “Dumb Shell” Approach

In this post I would like to address common thought that I hear from people regarding [Next Generation Shell](https://ngs-lang.org/), a new programming language and a shell that I’m working on. Note that other shells which are more advanced than POSIX shells also get this. [Quoting @cup from lobste.rs](https://lobste.rs/s/gert97/section_syntax_next_generation_shell#c_q6ky8i):

> Wouldnt it be better to just have a dumb shell, that can call programs to do heavy lifting (read: programming languages). This way you have a “division of labor”. Shell works best for launching executables, and programming languages work best for handling data structures and algorithms.

**No, it would not. I refuse to accept under-powered tools.**

## Dumbness is Fundamental Flaw

The “dumb shell” has no semantic understanding and doesn’t care about programs’ inputs nor outputs. Let’s see how it plays out.

Today, **“Understanding” of programs’ inputs** is covered by [completion](https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html). Completion was added because “dumb shell” had horrible user experience. It’s slightly better now when the shell “understands” programs’ input to some degree. To some people completion is a scope creep. I think of it as better user experience and productivity gain.

**“Understanding” of programs’ outputs?** We are not there yet. It also seems that interacting with objects on the screen is too novel of an idea for the shell. Considering how much time this idea is out there: WTF?

Let’s see how this “dumbness” manifests as bad user experience even at the very basic, “intended” functionality:

## Programs’ Output – Size

Do you know of any real world scenario when a human supposed to go over 10K lines on the screen? I mean just sit there and read it. Let me know. I’ve never seen such use case.

The shell is dumb, the shell “does not intervene” in programs’ outputs. Sounds good until you get unlimited number of lines dumped on your screen.

“Should have used `less`” you think later. Right. What if you forgot? The buffer is now filled with useless output and you can’t see outputs of previous programs. Are you being punished? No, just nobody cared about the UX. Alternatively, “it would be to complicated to implement”.

## Programs’ Output – All Mixed

1. Want to know what’s on your screen is stdout and what is stderr? Well… you can’t. Your shell is dumb, it doesn’t deal with things like that.
2. Want to know from which program the output came from? Nope. Some programs cope with that to some degree by prepending their name to error messages: `ls xxx` gives you `ls: xxx: No such file or directory`. What a wonderful strategy! Keep the shell dumb and **push the burden to all the programs**.
3. You can’t type because some background job is continuing to dump text on the screen where you are trying to work? Too bad, should have used redirection because guess what … you shell doesn’t handle that either… and you can’t add redirection after the program is running; again not shell’s business.

## Programs’ Output – Semantic Understanding

You just typed `aws ec2 describe instances --filters ...` and now you have some output.

You now see on your screen instance you would like to stop. The ID of the instance is right in front of your face. Now you type `aws ec2 stop-instances --instance-ids`. You would like to append the instance ID that you see on the screen. Nope. Your shell doesn’t do that. Too dumb. Select with the mouse and paste, because f\*ck you!

_Side note: amazing AWS engineers [did not include any human readable output format](https://ilya-sher.org/2016/05/06/aws-cli-inhuman-output-and-what-i-suggest/) so you get JSON dumped on your screen (or any other format which is still non-human-compatible)._

Let’s imagine for a moment that the command output had some semantic meaning to the shell.

1. The shell would display the output as a table.
2. The table would be interactive (interactive output, what a heresy!) and one could navigate with arrow keys and have a shortcut for copy/paste the current cell value to the command line (for completion).
3. You could interact with the objects in the table with the mouse (very new concept, another heresy for the shell).
4. How about instead of typing `aws ec2 stop-instances --instance-ids` you navigate to the correct line, press enter, choose “stop” from the menu and the command is constructed for you? `aws ec2 stop-instances --instance-ids i-123...` amazing, ha? Well, your shell can’t do that.
5. 

> Meaning, do you speak it mo\*\*\*er?

How about after performing operations using the UI you would get as per your choice one of the below snippets which would re-create the operation:

1. CLI commands
2. CloudFormation tempalte
3. Terraform “code”

## Solution: UI for the Shell

> Suppose I agree for a second, what do you suggest?

[https://github.com/ngs-lang/ngs/wiki/UI-Design](https://github.com/ngs-lang/ngs/wiki/UI-Design)

I personally don’t see how the described features could be implemented as external programs, keeping the shell “dumb”.

## We Can Do Better Today

The reality has changed. What was once amazing is subpar by today’s standards. The world outside of the shell moved forward while the shell stayed almost the same. Brilliant design? Brilliant what?

Let’s move this industry together from the stone age of bash shell to the bronze age of something a bit less subpar – [Next Generation Shell](https://ngs-lang.org).

## Closing Rant

Imaginary UNIX people:

> We wanted to separate things because they are semantically different so we split the things into stdout and stderr. Well… stderr was is actually for everything that is not stdout.
> 
> One bit of metadata (stdout vs stderr) for semantic meaning of the output should be enough for everyone forever. Well… at least it’s simple for us to implement.

> One of the greatest misnomers: stderr. Should be stddmp – dumpster for everything that is not stdout: logs, warnings, errors, …[#unix](https://twitter.com/hashtag/unix?src=hash&ref_src=twsrc%5Etfw)
> 
> — Ilya Sher (@ilya\_sher\_prog) [November 4, 2019](https://twitter.com/ilya_sher_prog/status/1191392071036395520?ref_src=twsrc%5Etfw)

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

* * *

Update: [discussion on lobste.rs](https://lobste.rs/s/b8xanw/use_dumb_shell_don_t_reinvent_wheel)