5 ms·
I don't buy into this argument either. Using python for shell scripting requires extensive knowledge about the language and the standard library and all the go
by hsn915 5y ago
I don't buy into this argument either.
Using python for shell scripting requires extensive knowledge about the language and the standard library and all the gotchas that you can fall into.
This sort of time investment does not pay off if you just want to write small scripts that perform simple tasks.
If the task is simple, then a bash script would be better.
If the task is not so simple, then a language you are really familar with is better.
If you accept my premise about how programming in slow languages is generally a bad idea, you would not spend that much time learning any such language with all its ins and outs and gotchas.
For background, I personally have spent a lot of time learning python, and only later in life have a realizd what a mistake that was. Now I only use Go for server side programming. I'm also using it for command-line programs. Such programs usually start small but grow over time. Choosing Python for them would have been a costly mistake.
- flohofwoe 5y ago> If the task is simple, then a bash script would be better. Bash script don't work on the Windows command line, and bash relies on UNIX tools as its "standard library", which also are not available on the Windows command line. That's the whole point really, Python has very good cross-platform support (and in this case cross-platform doesn't just mean "Linux and macOS", but also Windows). > If the task is not so simple, then a language you are really familar with is better. IMHO every programmer should be familiar with at least a handful programming languages.
- hsn915 5y agoBash can and does work on windows if you install it. Just like Python. Also doesn't windows now ship with a linux compatibility layer anyway (WSL)? EDIT: I just realized you are the guy who wrote sokol! If your main work station is windows and you don't work on linux, then replace bash from my previous comment with bat(ch).
- flohofwoe 5y agoBash is not the standard shell on Windows, and it also relies very much on UNIX-style filesystem conventions that don't map very well to the Windows environment. I wouldn't ask my users to install PowerShell on Linux or macOS either. Asking Windows users to run Bash scripts is essentially the same as asking them to build a C/C++ project that uses Autotools and Makefiles. It may work with lots of tinkering, but it's a massive world of pain. > If your main work station is windows and you don't work on linux, then replace bash from my previous comment with bat(ch). I usually switch between macOS, Linux and Windows at least several times a week, sometimes several times a day, maintaining different scripts to do the same thing wouldn't make sense.
- Supermancho 5y ago> Bash is not the standard shell on Windows, and it also relies very much on UNIX-style filesystem conventions that don't map very well to the Windows environment. Windows was built by people who started by copying from Unix. This is part of the reason Bash works fine on Windows (ie What is your problem with it "mapping" to things?). You can pipe commands, you can stream text, you can edit binaries. There are things that slow down (or can't be done, modify permissions easily, etc) because of Windows tradeoffs, not because it's fundamentally different. An OS does OS things and a shell talks to the OS.
- goohle 5y agoJust write in the header of the script: "This script requires Fedora Linux 33 or higher" and forget about outdated OS'es, unless it's your paid job to supported them. If you OS vendor refuses to supply you with appropriate tools to do your job, then just chose another vendor. Vote with your foots.
- BiteCode_dev 5y agoTalking about gotchas and then recommend bash is not a sign of credibility in my book. Bash has one strong point: 4 to 5 lines admin scripts for which concision and expressiveness matter more than anything else. That's it. There is nothing else it can be better at than ruby, python, perl, php, or even go or kotlin. The argument you need to learn x stands for bash as well, btw.
- hsn915 5y agoI only said to use bash for small scripts. Basically just a series of commands. Maybe setting up one or two environment variables. Anything more complex or involving "if" I would almost never write in bash.