Shell language and programming languages

Posix sh is kind of a mess, but more than any other language, it’s hard to do anything about it without losing the advantages and pragmatism of the system in the first place. I wonder if there’s a happy medium where a full language, with all the advantages of full languages, could be used as a shell without being inconvenient.

I seem to remember some such system being available for python, although it escapes me now, and there are projects like janet shell which aim to mix the two. But janet shell still keeps the shell syntax alongside janet’s syntax. I guess it’s just inconvenient having to type parentheses all the time.

One thing that i would like in shell is for > to work when taking input and output from the same file. That is, “cat file.txt > file.txt” shouldn’t result in an empty file because the file was initialized as empty before it started reading from it. Just a little gripe.

The shell pipe seems to me to be essentially a map and filter function, that applies a function to a bunch of list elements, or lines. This is clever and efficient. It’s a cool idea. It probably works best if there’s one data type (string) and one data structure (one-dimensional array, more or less). It could work well on the assumption that there’s a global instance of that data type that everything applies to, like forth does.

I’m not fully convinced by the push for structured data in command lines, because different types of data require different structures. Overall it’s much easier to let programs output data to an informal standard (eg. one line per record holding whatever) and let functions act in arbitrary ways on that unstructured data as necessary. Enforced structure breeds chaos. By starting with chaos, convention forms.

𓈝

This site is a part of the no ai webring. Travel backward, travel forward, or try a random site!