python_vs_shell¶
Eliminating the need to write shell-scripts is a side goal of protoprimer.
See also the motivation section in the main readme.md.
What are python advantages?¶
There are multiple advantages of python over shell scripts (e.g. bash):
Test-ability -
bashscripts are hardly test-able.There is simply not practice to write tests for
bashscripts.Trace-ability - failures do not produce stack traces in
bash.Lack of trace-ability and test-ability encourage excessive logging for
bashscripts (includingset -xv).More readable code in
pythonthan in shell scripts.Think of functions, classes, modules, ...
Clean support for various data structures.
Start with
list,dict, ...Avoid initializing automatic error detection for sub-shell (e.g.
set -euo pipefail).Execution of shell scripts (by default) allows undefined variables, failing commands, ...
Better control of local versus global variables.
No issues with
returnversusexit.When a script is
source-d, one has to selectreturn, otherwise, for a stand-alone script,exitmust be used.Unpredictable
alias-es set by user inbash.They can be ignored by
commandbut that make suchbashscript even more cumbersome to write.Speed.
What are shell advantages?¶
Primarily WYSIWYG for CLI.
Essentially, a shell script is what a human would type interactively. This implies succinct syntax (and may seem helpful, but quickly becomes cryptic).