Live data from Hacker News

Bashing the Bash – Replacing Shell Scripts with Python (2017)

medium.com

21–30 of 138 posts

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#21

I think this article is supposed to commend Python as a better choice than Bash? I think the author forgot to make a convincing argument for that, though. > The point of bash-bashing is to reduce use of the shell. That's a tautology. I get it, we're supposed to reduce the use of bash ... but why? > Without much real work, it’s easy to replace shell scripts with Python code. But you're writing the same thing again? Th…

I've written extensive programs in Haskell, and yet I also have many Bash scripts.

I go back and forth. For the longest time I ignored Perl and just wrote scripts in C. Then I learned Perl, then Python. I prefer Ruby for no better reason than it's less boring. These scripting languages share a common strength: nested hash tables make everything easier. Still, I'd revert to Bash, explaining that if you can't accomplish the same thing with virtual text files in Bash you don't really understand Bash.

Nevertheless, switching from Bash to Ruby is like taking off a heavy backpack after a long day hiking. Who needs a joint when the weight is off your shoulders?

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#24

I was hoping someone finally had a library or something to make python good at the things shell does well (mostly, running stuff and piping output around). If only. This really just reads like someone who doesn't know shell and does know python, but thinks the problem is the tool. They continually describe shell with phrases like "obscure and difficult-to-predict" while talking through things that are either obvious…

https://amoffat.github.io/sh/

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#25
post #11

Earlier quoted context omitted.

bash is anti-bicycle: no matter how long you use, it trips you up. https://www.oilshell.org/why.html Shell is great for one liners to run commands, cancerous for anything more complex. Fabric combines the best of both worlds: shell for one liners, Python for more complex logic https://docs.fabfile.org/en/2.6/getting-started.html#addendu...

In my experience, it trips me up no more than Python or Fabric do. I have used Fabric a lot too. At another job, we built all of our pipeline tooling in it. I somehow keep returning to Bash, though. I enjoy it.

[deleted]

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#26
I myself kind of went full circle. I started mostly python, then started to really embrace bash, mainly because I joined a company where everyone else used it a ton, got pretty decent at it. Even wrote basically a primitive container orchestrator in Bash because my PM didn't want to use anything "newfangled". Then I joined a startup at basically the ground floor, and it's almost entirely pure python, with some Makefiles to automate common operations. All that to say, I have a lot of experience with both paradigms.

And frankly...bash kinda sucks as a programming language and environment. It's a footgun factory. Even when I was most fluent, I constantly had to deal with nested quotes, escaping, stringly types, empty variables, implicit behavior.

Python's biggest weak point is definitely its packaging and dependency ecosystem... but it at least has one. Bash doesn't even have modules. And it's gotten MUCH better over the years, with pyproject.toml, poetry, actual version resolvers, pipx makes managing venvs for cli tools way easier.

"but bash is everywhere" says many folks. yeah, and? There was a point in time where it wasn't. Python is seeing way more market penetration.

Xonsh (python based shell) and plumbum (python library which makes pipe-operating and subprocessing easier) are both great.

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#27
post #5

Beware of Python devs writing Python shell scripts. They're used to using all the brand new (backwards incompatible) language features as soon as they come out. The vast majority have no consideration for a 10 year old PC running a 10 year old OS. The python3.x they write will not run. Bash, surprisingly, gets backwards incompatible language features too. But the vast majority of bash developers are writing for all c…

> The vast majority have no consideration for a 10 year old PC running a 10 year old OS. The python3.x they write will not run.

Python3 is just under 14 years old.

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#28

I think this article is supposed to commend Python as a better choice than Bash? I think the author forgot to make a convincing argument for that, though. > The point of bash-bashing is to reduce use of the shell. That's a tautology. I get it, we're supposed to reduce the use of bash ... but why? > Without much real work, it’s easy to replace shell scripts with Python code. But you're writing the same thing again? Th…

Any data to support it?

There isn't any "data" on these things. It's a qualitative, holistic assessment of the risk-benefit tradeoff between two choices. Like much of life in general, in fact.

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#29
I once worked for a company that had a product which had a fairly complicated and time-consuming build process. Someone had written a distributed build process using the traditional CMD.exe shell scripting language. It was running multiple processes in parallel, and they communicated by writing and reading text files. Later they added PowerShell scripts. All in all, there were tens of thousands of lines of PS and BAT scripts. It was quite a nightmare.

The team was supposed to maintain this mess. We decided to create a compiler that translated .BAT scripts to C#. The idea was that the C# code would be easier to understand and modify. I left before it was complete, so I'm not sure how that worked out. But last I heard, they were pleased that some parts of it now ran thousands of times faster.

Re: Bashing the Bash – Replacing Shell Scripts with Python (2017)

#30
Im dealing with some python3 crap today on my main laptop.

Primarily, because of a library I compiled and installed, I'm getting other nasty side effects form it. Primarily that protonvpn-cli isnt now running becasue of some broken library.

I've never had bash break like that. Quirks, sure. But never this sort of brokenness.

Post reply on HN