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 - bash scripts are hardly test-able.

    There is simply not practice to write tests for bash scripts.

  • Trace-ability - failures do not produce stack traces in bash.

    Lack of trace-ability and test-ability encourage excessive logging for bash scripts (including set -xv).

  • More readable code in python than 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 return versus exit.

    When a script is source-d, one has to select return, otherwise, for a stand-alone script, exit must be used.

  • Unpredictable alias-es set by user in bash.

    They can be ignored by command but that make such bash script 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).