4 ms·
Once you need concurrency or have anything but the most basic logic almost anything trumps bash. It’s possible to implement basically anything in bash, of cours
by cranekam 5y ago
Once you need concurrency or have anything but the most basic logic almost anything trumps bash. It’s possible to implement basically anything in bash, of course, but that doesn’t make it sensible. Its error handling is poor, there are too many ways to do things (eg [ vs [[ vs test), dealing with non-scalar data is a pain, it has subtle gotchas (accidentally spawning a subshell and shadowing variables), it’s cryptic (${foo#bar} and friends are cool but much harder to remember than something like .replace()), and so on.
If I’m just writing small tools that wire a few basic commands together bash is fine. For anything that actually needs data to be crunched or decent error handling Python, Go, Perl (though also cryptic), C++ are, IMO, a far better choice.
- atribecalledqst 5y agoThe cryptic nature of Bash syntax is why I generally try to do all my scripting in Python these days, if it exceeds a certain level of complexity. i.e. if I want to just group a bunch of shell commands together with no special logic, Bash is usually OK. For anything more complicated than an if statement or while loop I have to refer back to old scripts to remember the syntax. Not an ideal situation. I did recently have a case where I needed to run a shell command with a multi-line output, and an easy call to os.popen() wasn't returning the full output. So, back to Bash arrays and weird text parsing syntax (IFS=" " read tempArray...) I went...