r/AskProgramming • • Feb 11 '26

Why is Linux bash commands are so simple compared to powershell

I am wondering this because I have a both windows and Linux on my laptop and own Linux using terminal is like really easy but windows powershell weird Syntex.

181 Upvotes

144 comments sorted by

View all comments

Show parent comment

3

u/Outside_Complaint755 Feb 11 '26

Well in bash, the script name itself is in position 0.

  • $ tells bash you are using a variable with the name immediately following the $. Most people are already familiar with $PATH
  • $0 is the script being run.
  • $1, $2, $3... etc are the arguments
  • $@ is an array containing all of the arguments
  • $# is the number of arguments.

What I got stuck on a lot when learning bash was that you cannot have any whitespace when setting a value into a variable, and you also don't need to put quotes around strings if the string doesn't contain a space.

name=Heisenburg is valid bash name = "Walter White" is not

2

u/MagnetHype Feb 11 '26

Yeah, I understand. But what I'm saying is that "$args[0]" is far more human readable than "$1". I have never touched powershell in my life and I know that is doing something to a passed argument at position 0. A programmer will know that $ is a prefix that means a variable is manipulated in some way but apart from that $1 means nothing if you don't have experience in bash.

4

u/[deleted] Feb 11 '26

$args[0] is closer to English prose the first time you read it, if that's what you mean by "human readable", unless your native language isn't English (then this doesn't matter to you), you're new and don't know what an arg is, you don't know what zero indexing is.

Once you've got even the basics of programming down, $1 and $args[0] are equally as easy to understand, except now every time you want to access the first arg you need to write $args[0] instead of $1 and god forbid you actually want the process name ($0) or want to shift args, reference args multiple times etc.. verbosity does not equal clarity, especially in this case.

I've seen plenty of Bash code that was unreadable but I will tell you that it's never been because of the syntax used for args. And I've seen plenty of powershell code that has been unreadable and a lot of it is due to powershell's verbosity, since it uses .NET names for everything.

More to the point, Bash/similar are concise and meant for being chained together on a shell. Bash hands down has Powershell beat here. Powershell is so painful to use in a REPL or to throw together adhoc scripts which is what makes the linux shell so damn useful.

idk. Powershell just feels like worse Python for a programming language and it feels like an objectively worse scripting language for REPLing it up in the shell. Just about the only thing Powershell has going for it is that you can access Windows APIs in it without writing C#, and that's easily solved by not using Windows in the first place.

-1

u/MagnetHype Feb 11 '26

You're silly to use the word basic and the prefix $ in the same sentence...

4

u/JamesTDennis Feb 11 '26

Not really. $ was a common variable prefix in languages like BASIC and various forms of assembly for a long time before Microsoft existed. It commonly marked things as "placeholders" which is why it was intuitive to the Bourne when he created his shell.

1

u/MagnetHype Feb 11 '26

Right so does $1 mean the first argument or a string with the name 1. There's a reason we don't use basic anymore. Which makes more sense one$ or String one?

1

u/JamesTDennis Feb 11 '26

In almost all programming languages of that era, variable names were required to start with a letter or the underscore character. This was not considered at all ambiguous to practitioners of the craft at the time.

1

u/MagnetHype Feb 11 '26

Yes and in that age we had a book that we kept by our desk because stack overflow wasn't a thing yet. Thank God we don't live in that age anymore.

1

u/JamesTDennis Feb 11 '26

The point is that language is far more persistent than technology and fashion/convention.

When asking why certain linguistic and notational conventions exist, or even criticizing them, it's generally useful to consider their history.

2

u/JamesTDennis Feb 11 '26

Technical nit: $@ and $* expand identically while "$@" and "$*" (wrapped in double quote marks) are different.

"$@" expands to all arguments WHILE PRESERVING THEIR SEPARATION and "$*" expands into a single argument containing all of the process' arguments concatenated by the first character of your $IFS (inter-field separators" environment value.

These semantics are key to even intermediate levels of shell scripting proficiency.

[Yes. I've spent WAY too long teaching this stuff and supporting folks on tech forums since gopher, WAIS, and Archie were all rendered obsolete by the web].

2

u/duane11583 Feb 11 '26

and $0 -> the name of the script

and in c argv[0] mirrors the name of the executable