19762 shaares
136 private links
136 private links
The fundamental problem of shells is they are required to be two things.
A high-frequency REPL, which requires terseness, short command names, little to no syntax, implicit rather than explicit, so as to minimize the duration of REPL cycles.
A programming language, which requires readable and maintainable syntax, static types, modules, visibility, declarations, explicit configuration rather than implicit conventions.
And you can’t do both. You can’t be explicit and implicit, you can’t be terse and readable, you can’t be flexible and robust.
Shells optimize the former case, so that you can write cat beef.txt | grep "lasagna" | sort -n | uniq instead of:
with open(Path("beef.txt")) as stream:
lines = filter(
stream.readlines(),
lambda line: re.match(line, "lasagna") is not None
)
print(set(reverse(sorted(lines))))
Which does not spark joy.
So the programming language aspect suffers: shell scripts are an unreadable nightmare of stringly-typed code resembling cyphertext.