46
submitted 1 year ago* (last edited 1 year ago) by GodOfThunder@lemm.ee to c/linux@lemmy.ml

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.
you are viewing a single comment's thread
view the rest of the comments
[-] seperis@lemmy.ml 2 points 1 year ago

Because for what it was made to do and what I want to use it for, it's utterly ideal. It's easy, it's direct, it works seamlessly with any program's command line, and I can run anything network-wide on any linux machine on my network out of box with no fiddling around. No check for version, no missing packages to hunt up, no libraries to download and verify; I type, I save, it runs, I'm done. If I need to integrate command line tools on six separate programs and/or five to eight scripts in two languages to do a stat/resource/network check on my Linux machines, I can do them all from one script and I can do it to six separate machines over ssh in a loop in under 200 lines of code and throw the results up on a webpage in apache with another thirty if I want to make it pretty in html. Then I set it to a cron job to run once an hour and forget it for months; it keeps on keeping on, I just check that webpage to see everything is fine, in separate tabs even. And I can do all that very very very fast and literally out of box; if I add a brand new machine, all I do is copy my base bash library over and set permissions and it's ready to go.

Those scripts will always work, on every linux machine, every time, in the same way; they will run in ubuntu, solus, fedora, arch, debian, raspberry pi, probably slackware I haven't checked, the scripts do not care. Ones I wrote ten years ago are still running just fine.

Bash is kind of like the general of my script and cli army; she does not need to know everything herself, she just needs to organize the troops to do their jobs, and tell me if someone's slacking off because python decided to be a dick about a package or php is being cranky or apache just won't speak to anyone no idea wtf is going on there or otbr vanished into the ether or all my wifi drivers are in revolt after an update. She does not stress me at all; she is the finder of my stresses before the drama hits critical, and this is why she is my favorite.

this post was submitted on 12 Jul 2023
46 points (79.5% liked)

Linux

48080 readers
764 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS