Hacker News new | ask | show | jobs
by CuriouslyC 817 days ago
No! General purpose scripts should almost always be written in bash. It's basically the best language for doing simple things with files, it's universally available and it makes almost no assumptions about the environment in which it executes.

Have windows users use WSL (the VSCode integration is great!), and mac users should install GNU tools since the system tools are obnoxiously incompatible.

The only time I've found that scripts should be in another language is:

1. You need to call libs that to do something fancy and it would be too troublesome to make a small Unix style executable to do the thing. 2. The developers on your team lack Unix/bash experience, and you don't trust them to learn in a timely manner (sad).

2 comments

> Have windows users use WSL (the VSCode integration is great!), and mac users should install GNU tools since the system tools are obnoxiously incompatible.

At that point you might as well target Python 3.6. Seems like the same hassle for the developer to install and you don't have to worry about wonky differences for users who haven't installed GNU tools, but still think they can run your script because it says `.sh`

That's not correct, because then you have to make sure all your docker images and deployment environments have the correct version of python, and managing python installations for incompetent Mac devs is probably more work than managing a GNU utils install since python installs have been known to break easily whereas the core utils are rock solid. Plus writing file manipulation/subprocess scripts in python is really awkward compared to bash.
Sad that you're being downvoted for the truth.

Unless you're doing some extremely niche work, Bash >= 3.2 (because Mac) is nearly always going to be available. Even if it _isn't_, there will still be sh or dash, and it's not _that_ hard to stick with pure POSIX for most small uses.

The last time I (by which I mean my team) rewrote a script from Bash into Python was because it had gotten unwieldy over time, I was the sole maintainer, and very few other people at the company knew Bash well enough to understand some of it. The upside was testing frameworks in Python are way better than Bash.

First you write in shell without knowing the language, and blow your foot off. A few years go by. "I should use a _real_ language, I'm not an amateur anymore." So you write everything in Python. A few years go by. "I should learn shell, and use it only when appropriate."

Maybe this is what Perl is for, but I never learned it.