News for hackers. Stuff that matters.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by DyslexicAtheist on Saturday March 26, 2022 @04:32AM (#30810226)
> 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.

Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by rhn_mk1 on Saturday March 26, 2022 @04:38AM (#30810243)
Judging 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.

Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by DyslexicAtheist on Saturday March 26, 2022 @05:13AM (#30810387)
> 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.

Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by psd1 on Saturday March 26, 2022 @06:15AM (#30810625)
Anything is unmaintainable if the maintainers don't have the foundational skills.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by teddyh on Saturday March 26, 2022 @07:38AM (#30810986)
In which case those people are not actually maintainers.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by tempodox on Saturday March 26, 2022 @07:23AM (#30810906)
If the kids refuse to learn anything new (to them), they chose the wrong occupation.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by kaba0 on Saturday March 26, 2022 @01:37PM (#30813706)
How is bash performant? It is literally interpret by lines, and starting a whole process per if statements..
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by bdowling on Sunday March 27, 2022 @02:53AM (#30818304)
> 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.

Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by kaba0 on Sunday March 27, 2022 @04:55AM (#30818786)
Still doesn’t make it fast in any meaning of the word, which was my original criticism.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by bdowling on Sunday March 27, 2022 @01:37PM (#30822185)
You 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.
Re:Bashing the Bash – Replacing Shell Scripts with Python (2... by Izkata on Saturday March 26, 2022 @03:34PM (#30814660)
Guessing: Automatic parallelization in pipelines, just as long as there isn't a wall that has to consume all its input like "sort".