HACKER Q&A
📣 amichail

Why learn shell programming? Why not just use Python/Julia instead?


Why learn shell programming? Why not just use Python/Julia instead?


  👤 jstx1 Accepted Answer ✓
Let's be real - how many people really learn shell programming? Most of it is figuring stuff out as you need it (if ever) because for most developers it's not the main part of their job.

Some reasons not to use Julia is that it isn't available everywhere, it's fairly new, slow to start up and very few people use it for this. The last point matters when you need to work with other people; if you're by yourself on your own machine, go wild and use whatever you like.


👤 ok_dad
The purpose of a shell script it's to do things in the shell that are best suited to the shell. Trying to use Python for that is fine, everyone prefers something different, but I already use the terminal for things like changing directories, 'ls', and etc, so it's easier for me to just write a shell script versus trying to figure out how to do it in Python, even if I use Python for work. The same question could be said of any other language you use daily: why not use Go or Java for the same things? The answer is that people do use those tools! It's basically individual preference, imo.

👤 voakbasda
On UNIX-like systems, the shell is a very powerful and universal tool, installed on most systems where other languages might not be as universally available (e.g embedded systems). I regularly write sophisticated scripts that automate workflows that would otherwise be performed entirely in the shell.

Using another language to run complex command line pipelines requires jumping through far too many hoops. I can always uninstall those other tools to get a smaller root filesystem image. Few distributions would survive having the system shell removed. The shell is integral.

That said, let me turn the question around: how would you automate shell command pipelines in Python/Julia/whatever and have it turn out as readable and universally accessible for future developers?

Amusingly, I feel like the original question could be rephrased as “why speak English? Chinese is more popular”… while standing in Times Square. Sure, you can take the road less traveled, but I think you will find the road steeper and longer.


👤 pope_meat
Everyone has their preferred method of cat skinning, and as long as the cat is separated from its skin in the end you've achieved your goal. Use the tool you're most familiar with unless your goal is to learn a new tool.

👤 marto1
It's a simple fact that if you're using a UNIX-like system you'll be using shells sooner or later. These shells run shell script(usually bash). In some systems like Debian(and derivatives) shell scripts are all over your system so any time something breaks or you want something added/disabled/deleted you'll probably be dealing with a shell script or something that is being read by one. So might as well spend the 1-2 hours required to learn how it works and then learn the rest on as-needed basis.

👤 smoldesu
Shell programming is ludicrously fast when you get used to it. Being able to automate repetitive tasks is the basis of building a powerful Unix machine, and extending that with loops and piping is a surprisingly stable and robust experience.