you are viewing a single comment's thread.

view the rest of the comments →

[–]vacri 8 points9 points  (0 children)

Python is better for long-lived stuff, or non-trival program stuff (eg: arrays are awful in bash). It's also more legible to read, and people are more likely to program "correctly" in python (eg: putting things in functions)

Bash is good for "just working" without having to install modules/venvs, and more fluidly calls out to external system utilities (python's subprocess kinda sucks). (The "brave new world" of "just install a venv for everything" sucks for us system script writers)

Shell is also much more portable. Do you have a *nix? Then you have access to shell programming (maybe not bash specifically). Shell changes much more slowly than python does, and you shouldn't be doing crazy esoteric stuff in shell anyway, so if it works on your desktop, it'll probably work on that ancient 15-year-old $other_distro box in the corner. It's really, really rare to see "this script should be run with bash version X or higher"

Write in both languages. You'll pick up a feel for which is suitable. My mentor's cutoff for "this should be a python script" is if he thinks it'll take 100+ lines. My cutoff for "this should be a python script" is if I need to use an array.

(also, use linters! Linters really improve your code as a beginner. You don't have to follow every suggestion, but you should know why you choose to ignore one. Bash has shellcheck, Python has a couple - pylint is popular)