4 ms·
> To say "you're holding it wrong" is just folly. Bash is worthy of the same treatment that "A Fractal of Bad Design" gave PHP, and it has no place in anything
by DyslexicAtheist 5y ago
> To say "you're holding it wrong" is just folly. Bash is worthy of the same treatment that "A Fractal of Bad Design" gave PHP, and it has no place in anything that wants to call itself engineering.
is this a cloud AMD64 opinion that ignores the 2 trillion devices which Gartner predicts will never run python?
I recently finished a ~600 lines ash script and the kids at work which just graduated complained that *"Y u no python?" For them it was difficult to understand because apparently I avoided cat/grep/dirname/basename/etc and used shell syntax wherever possible to avoid shelling out. (the thing I did would only run when system reaches a certain load)
Everyone forgot that the target hardware has only busybox (ash) and was massively resource constrained. My only options were to implement what I was doing as an eBPF, in C, or shell (ash). The shell script took 4 days (and was refactored/optimized several times within that period), the C (or eBPF) program would have taken ~10 days and the eBPF which is the best solution is unmaintainable once I leave the company.
from a performance perspective I take a bash script any time. Also python programs over time have a risk of eventually pulling in a dozen dependencies.
- rhn_mk1 5y agoJudging by the reaction of the kids at work, what you did is already unmaintainable. Plus, if you are running shell out of necessity on a constrained system, that doesn't mean shell deserves to be a programming language where there's actual choice.
- DyslexicAtheist 5y ago> what you did is already unmaintainable. how so? there is no python or perl or ruby etc on the target. what would have been a maintainable option other than /bin/sh ? C/C++ ? > where there's actual choice. again what choice? :) as I said there is no other solution than what I've given. the system literally doesn't have anything else regardless what "I think" it should support.
- psd1 5y agoAnything is unmaintainable if the maintainers don't have the foundational skills.
- teddyh 5y agoIn which case those people are not actually maintainers.
- tempodox 5y agoIf the kids refuse to learn anything new (to them), they chose the wrong occupation.
- kaba0 5y agoHow is bash performant? It is literally interpret by lines, and starting a whole process per if statements..
- Izkata 5y agoGuessing: Automatic parallelization in pipelines, just as long as there isn't a wall that has to consume all its input like "sort".
- bdowling 5y ago> How is bash performant? Typically, time spent interpreting control flow in a bash script is dwarfed by time spent in the programs called by the script. > It is literally interpret by lines It's just splitting lines into words to build up commands. It's not compiling C++. > starting a whole process per if statements.. In the common pattern `if command1; then command2; fi`, if command1 is a builtin (e.g., `test` or `[`), then bash does not create a subprocess.
- kaba0 5y agoStill doesn’t make it fast in any meaning of the word, which was my original criticism.
- bdowling 5y agoYou asked how bash is performant. I responded with reasons its performance is good in many applications. Here”s one more: bash starts up faster than other interpreters (e.g., Python), and startup time can often be a significant factor in overall performance.