thepracticaldev,
@thepracticaldev@fosstodon.org avatar

Bash is a terrible programming language, but what's the alternative ?

What's your favorite non-Bash language for your scripts?


https://dev.to/jmfayard/bash-is-a-terrible-programming-language-but-whats-the-alternative--oc2

meuon,
@meuon@fosstodon.org avatar

@thepracticaldev Perl.

Bash is a SHELL and isn't necessarily a programming language but can be pretty good. PERL was essentially created for system admin / automation and reporting. It is awesome at parsing log files and other sources, hence the nickname: Perfectly Eclectic Rubbish Lister

And don't laugh, but I do a lot of scripting (non web) work in PHP as well.

ramsey,
@ramsey@phpc.social avatar

@meuon @thepracticaldev I love Bash. Why are we bashing on Bash? Does @thepracticaldev support language-bashing, now?

Bash scripting, in fact, is not a terrible programming language.

taylan,
@taylan@pl.tkammer.de avatar

@ramsey @meuon @thepracticaldev

One can point at a number of objective flaws to criticise Bash as a language:

  • By default, undefined variables are treated as the empty string, which can escalate simple bugs (like a typo) into catastrophes like "rm -rf $foo/" becoming "rm -rf /" which happened in a version of Steam for GNU/Linux I believe. It's also happened to me in my early days, on my home PC.

  • Variables are split by whitespace after being expanded, if not wrapped in double quotes, which is counter intuitive and may also escalate simple bugs like in the above. For example, if the directories foo and "foo bar" both exist, and a variable is set to "foo bar", then "rm -rf $var" will be interpreted as "rm -rf foo bar" and thus remove foo instead of "foo bar" (and then say "bar not found").

  • No support for floating point numbers.

  • Syntax for hash tables is unnecessarily complicated.

  • Automatic subshell semantics in pipes cause strange variable scope issues... Difficult to explain and I don't have a good example in mind but if you know, you know.

  • No good support for reading data that isn't delimited by newlines, if I remember correctly.

There's probably many more things one could list.

ramsey,
@ramsey@phpc.social avatar

@taylan @meuon @thepracticaldev I love it when people claim things are objective.

ramsey,
@ramsey@phpc.social avatar

@meuon @thepracticaldev I just practically did a full rewrite of this, and it’s all in Bash, and it has unit tests, and everything. https://github.com/ramsey/asdf-php

ramsey,
@ramsey@phpc.social avatar

@meuon @thepracticaldev Something makes me think @thepracticaldev doesn’t monitor or participate in their community here in the Fediverse. They’re probably still supporting that bad guy on the other site. 😉

stfn,
@stfn@fosstodon.org avatar

@thepracticaldev Python, obviously

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • mdbf
  • rosin
  • slotface
  • InstantRegret
  • modclub
  • GTA5RPClips
  • kavyap
  • ethstaker
  • khanakhh
  • everett
  • JUstTest
  • ngwrru68w68
  • Durango
  • cisconetworking
  • osvaldo12
  • tester
  • cubers
  • anitta
  • tacticalgear
  • normalnudes
  • provamag3
  • megavids
  • Leos
  • lostlight
  • All magazines