3 ms·
> sh(1) (or bash - nobody cares) features feel archaic and brittle Maybe some shell features are not that great, but in general I feel the opposite. Many of th
by effie 9y ago
> sh(1) (or bash - nobody cares) features feel archaic and brittle
Maybe some shell features are not that great, but in general I feel the opposite. Many of the shell features are great and lacking in other, more general-purpose languages - for example, program composition via pipes, stdout/stderr redirection syntax, direct access to the filesystem, interchangeability of a function and a program call, and others.
When somebody decides to write a big system, like Kubernetes, they better be pragmatic rather than idealistic. That means choosing the right tool for the job, even if this tool has some deficiences or is considered quirky by some people. Manipulating VMs,containers on localhost or remote hosts, interacting with the OS and the filesystem, all on a unix-like system, it seems to me like shell is the best tool there is for most of the task.
- bch 9y ago> composition via pipes That’s a good, big one in favour of shells. Re: file system, std err/out, I’m not convinced, but pipes alone are worth a lot. I wasn’t thinking at all of pipes, and you’ve tipped the scales, but is it enough? Do Tcl/Perl/ruby/python/... compete in that space?
- jancsika 9y ago> Re: file system, std err/out, I’m not convinced, but pipes alone are worth a lot. How does the existence or lack of a standard data interchange format affect the value of those pipes?
- bch 9y agoIt seems to me that theoretically the effect is brutal. Practically, it’s negligible. We pipe everyday, all day, and the world carries on, so that’s a pragmatic vote of confidence for pipes. Are you trying to get me to write a “worse is better” essay that ends with “...and the existence and continued durability of shell scripts is proof enough that their place is not only justified, it’s vital!”, because it won’t work. Pipes are good. Shell scripts should be looked at suspiciously if they’re more than 20 lines long. ;)
- philipov 9y agoPipes aren't even something shell scripts have a monopoly on. They're just as easy to use in Perl. Perl may not be known for its readability, but it still ends up miles ahead of an equivalent script in bash. I do wish there was a first class syntax for it in Python (but you can get most of the way there by using generator/coroutine pipelines).
- chubot 9y agoFWIW this post is related: Pipelines Support Vectorized, Point-Free, and Imperative Style http://www.oilshell.org/blog/2017/01/15.html http://www.oilshell.org/blog/2017/01/15.html I started writing a series on "what shell can do that other languages can't", but I put it on hold until the shell is in better shape. I hope to resume that series in the next few months.