Comment by WorldMaker

Comment by WorldMaker 2 days ago

5 replies

There are ton of aliases. It's "impolite" [0] to use aliases in scripts and documentation so looking at PowerShell examples is way more verbose than actually using it day to day in a REPL. Sure I could write `Set-Location` a million times a day, but I just use `cd` in the old ways. Same with `Get-ChildItem`, I tend to just use `ls` myself because of ancient habits. (I find it interesting how many have been moving to `gci` instead as the more PowerShell-native `ls` alias. I've not been convinced to do that myself, but I think it has to do with `gci` is way more powerful than most shells' `ls` and is used to navigate everything from folder structures to object structures including that its not a bad `jq` if you convert JSON files to PowerShell objects.)

[0] It's from a version of the Python ethos that code is read way more often than it is written, so when you are polishing PowerShell code to share with others you expand all the aliases so that it is easier to read.

xelamonster 2 days ago

Using a different set of commands in the terminal versus scripts and documentation makes no sense to me, why would I want to learn two different ways do the same thing? Python does not expect me to use `open` in the REPL but prefer `get_file_handle` in published scripts, their ethos works because the entire language has an emphasis on relatively concise readability.

Every single command starting with `Get-` or `Set-` adds so much noise and makes things really hard to visually distinguish too. I don't want overly verbose commands in scripts for the same reason I don't want them in the terminal, it's still a pain to write and even if you have some autocomplete it makes editing harder. I don't think `ls` is any less clear or harder to learn than `Get-ChildItem` really, that name doesn't even actually give me any clue what the command does.

  • 7bit a day ago

    It's not hard to learn. And if you don't want to, then don't. That's really not something someone cares about, unless you're working in a team.

frenchyatwork 2 days ago

What about the part of the Python ethos where "There should be one-- and preferably only one --obvious way to do it"

  • WorldMaker 2 days ago

    A) PowerShell isn't Python, it doesn't have to (and doesn't) import the whole Python ethos, just the parts that make sense for a Shell and Shell language with different end goals.

    B) PowerShell doesn't care as much about the first part because shells have always had aliases and macros, but it does care about the second half "obvious way to do it". The other reason for starting with verbose names and aliasing them for day to day REPL use is to aid discovery. It's often very easy to discover which command or cmdlet does the thing you need simply because it is right there in the name. Sometimes you can just guess the name because there are only so many "allowed" verbs and you just need the noun you want to "verb". `Get-Help` can be quite powerful, `Get-Verb` can help explain some bits about what the verbosity is meant to mean. You can search for commands with `Get-Command`.

  • nerdponx a day ago

    Python itself doesn't follow that at all, ignore it.