Bash-like scripting has become ubiquitous in operating systems, and it makes me wonder about its widespread adoption despite lacking certain programming conveniences found in other languages. While it may not be the ideal choice for large-scale software development, the bash shell possesses unique features that make it well-suited for interactive command-line processing, including pipelining, text manipulation, and file handling. Why isn’t there an alternative that combines the best of bash’s command-line capabilities with the robustness and scalability of traditional programming languages. Why do even new operating systems, such as Redox OS, opt for a similar syntax rather than a completely different programming language?

Here are some of the limitations I find in Bash compared to other programming languages:

  1. Syntax and Expressiveness:

    • Bash has a relatively simple syntax compared to other programming languages. It lacks some advanced language features such as object-oriented programming, complex data structures, and advanced control flow constructs.
    • The syntax of Bash can be less intuitive and more error-prone, especially for complex tasks or larger projects.
  2. Performance:

    • Bash scripts can be slower compared to compiled languages like C or Java. This is because Bash is an interpreted language, and each line of code is interpreted at runtime.
    • Bash may not be the best choice for computationally intensive tasks or applications that require high performance.
  3. Error Handling and Debugging:

    • Error handling and debugging in Bash can be challenging. Bash does not provide robust error handling mechanisms, and error messages can be cryptic and difficult to interpret.
    • Debugging Bash scripts can be cumbersome, as there is limited tooling and debugging support compared to other programming languages.
  4. Portability:

    • While Bash is available on most Unix-like systems, it may not be available on all platforms or versions. This can limit the portability of Bash scripts.
    • Bash scripts may not work as expected on non-Unix systems or require modifications to run on different platforms.
  5. Limited Standard Library:

    • Bash has a limited standard library compared to other programming languages. It lacks comprehensive libraries for tasks such as networking, database access, or advanced data manipulation.
    • Bash often relies on external tools or utilities to perform complex operations, which can introduce dependencies and compatibility issues.
  6. Lack of Modularity and Reusability:

    • Bash scripts can become monolithic and difficult to maintain as they grow in size. Bash does not provide strong mechanisms for modularization or code reuse.
    • Reusing code or creating libraries in Bash can be challenging, leading to code duplication and decreased maintainability.
  • @nous
    link
    81 year ago

    I’m guessing some relatively recent version of Python 2 is standard on many machines.

    I hope not. Python2 has been EOL for a long time now and should not be used any more. And I really hate pythons dependency management.

    • maegul (he/they)
      link
      fedilink
      11 year ago

      Except this is about Bash … not bashing Python.

      First, Python2 need not be EOL. I’m clearly talking about some parallel timeline where python as a *nix shell became a project and got traction. Somewhere around ~2000, when python2 was first released, some project works on making the necessary adaptations for a shell and presumably gets that working well.

      Second, we’re talking about Bash and Bash scripts, any serious dependency management or package management doesn’t really factor into this, it seems you’re bashing Python as a fully fledged programming language.

      The weakest point in my imaginary proposal, IMO, is getting python to work as a shell language. As a scripting language it’s fine and many are happy using it where Bash might be used. But as a shell, and in scripting too, it’s interop with core utils and commands is pretty suboptimal. Ergonomics would at some point require something to be done about that and I don’t know what a successful version of that would look like. If we’re talking about a POSIX standard, maybe all that’d be necessary would be a standard library that wraps everything needed? Or a nicer object/function/syntax for calling subprocesses, which various third party libs have tried obviously. The Xonsh project also comes to mind … a superset of python, which is a great idea IMO but maybe undermines the idea that python2 is everywhere already.

      • @nous
        link
        11 year ago

        I’m clearly talking about some parallel timeline

        That is not clear at all from your first post. All you did was ask about the current state and postulate that python2 should be commonly installed nowadays. Then wonder if python could be made to act like a shell. None of that indicated you were thinking about some hypothetical parallel past timeline.

        In our timeline python 2 is EOL and not installed by default on much if anything these days and should not be used by anything any more (despite some things still needing it - they really shouldn’t any more).

      • 0xtero
        link
        fedilink
        1
        edit-2
        1 year ago

        First, Python2 need not be EOL.

        No. Python2 absolutely needs to be EOL. Let it die and be buried. Never to be resurrected again.
        python2 was finally removed from Debian at the end of last year.
        https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1027108

        It does not need to come back - and it especially does not need to become a shell built-in

        python2 is everywhere already

        That’s just not correct. It is not part of any modern distro by default. Even RH are planning on dropping it next year

        • maegul (he/they)
          link
          fedilink
          11 year ago

          I’m talking about an alternative timeline where python as a good and widely available *nix shell becomes a thing. For that to have every happened it would have had to start with python2. I’m not advocating for python2 to be brought back now or anything like that.