Hacker News new | ask | show | jobs
by doorhammer 1141 days ago
> The powershell command names though

Just wondering if you're talking about command name length or something else?

Asking because it comes up a lot and almost all the common commands have idiomatic short/terse versions (gci for Get-ChildItem, etc).

No shade, though. No reason you'd know if you don't have a reason to know it.

Would love to hear if I'm making the wrong assumption and it's something else you're talking about. I personally really love powershell, but also get why people love bash. I'm still pretty comfortable with bash because I work in *nix systems mostly, so it makes sense for me to know it, whereas the reverse (with ps) isn't really true for most devs

5 comments

Yeah that's basically it, so thanks for mentioning abbreviations! I knew they had some aliases (e.g. ls, curl) but not that it was commonplace because any powershell tutorial uses the long form and capitalizes everything (indeed I don't interact with PS a lot). It all feels very design-by-committee. Not sure whether it's a good thing that guides never use the short form: long more readable, but the specific choices of words give me weird vibes and run off blog-width line lengths. OP shows that nicely with the bash version fitting on ~60% of the line (on my screen) but the PS version running out of the line.

A lot has been written about naming things and brevity versus clarity, and while I sit very firmly on the programmer's side as opposed to the math people side (single letter variable names, in weird fonts or languages if they (surprise!) run out of available letters), I think I am more of a bash person than a java person in terms of naming things. Word-ish commands like pushd, kill, read, etc. (taking some bash built-ins here as examples, rather than external programs which may be named arbitrarily) seem a lot nicer to me than either very long commands or acronyms where you basically still have to know the long form to remember it. I'd never have guessed that spps stands for stop-process yet that's the portable powershell form of 'kill' (just looked that one up).

I think this kinda shows the issue, and why I personally prefer ps (as someone who's bounced off bash and NEVER gotten the time to get decent at it, and who rarely needs to use any of these and never at any serious level, so massive grain of salt).

Kill is intuitive to you because you've probably been around tech your whole life, and tech has just used "kill" ever since. It's essentially as ubiquitous as "bug".

That said, if I had to teach someone brand new with next to no skills (the endless goal of making coding easier for the average person and so on), Stop-Process is a hell of a lot easier to teach, or rather, it's much easier to teach them to help themselves.

Since it follows the same naming template as every other powershell command, if you teach them how to use the basic commands like Get-Help/Get-Command, they're a hell of a lot more likely to figure it out themselves without needing assistance. You know that every cmdlet is verb-noun, and you know you're trying to stop a process, so something like

> Get-Command "*process*"

Gives you a short list that is extremely intuitive to figure out.

Now...for something as simple as "kill" you're not expecting a beginner to run a command with a wildcard search. You'll just tell them. But that entire philosophy is extremely helpful when you're in a situation where you do need to figure out the command and don't have the ability to just spend however many minutes on google, and if you teach PS right you get to a point where it's very easy to teach yourself.

Obviously how much this matters in a world of IDE's and search engines and now AI is questionable, but I think that if you redid bash today, it'd follow similar philosophies. Things like touch, grep, and arguably even echo really strike me as "favorites" just because of the inertia/ubiquity.

The convention is to use the short form whenever you are in a terminal for one-off commands, but go for the full name for script files that has to be maintained/read later — which is an absolutely sane policy in my opinion.

Bash is a write-only-full-of-bugs language, comparatively.

100% and I never thought of that before but I can see how you'd get that impression from tutorials.

The VSCode powershell extensions will also give you suggestion squigglies under all of your aliases in a saved script if they're not long-form, but I usually mix and match based on pragmatism.

My use of alias vs long-form usually comes down to two sort of situations:

* Ad-hoc at the shell: all aliases all the time (and make my own if I need to. welcome to my godless wasteland, population: me) * Shared scripts: Just like any code, do what's idiomatic for the team. Usually it's largely aliases with some long-form

In practice I'd say the formatting consistency situation on teams isn't nearly as bad as SQL but obviously not as good as Go.

For reference, I'm also a huge APL fan, so hit me with arcane symbols in my free-time all day long, but definitely pragmatic balance at work.

I also don't even think of them as acronyms personally. The acronym just sort of means the semantic action in my brain at this point, but I think that's mostly a fluency thing, and can't really speak to it being hurtful/helpful since I'm so removed from when I first started learning it

Regarding not thinking of them as acronyms: yeah I get that. I was wondering how to best phrase that sentence because, indeed, curl also does not stand for C Uniform Resource Locator in my head, or grep for global regular expression perl-style (if I'm remembering that one correctly). It's just curl and grep. However, whereas curl and grep are really treated as names, spps I can currently regurgitate only by thinking of stop-process, and I imagine most such abbreviations will be like that for a while.
totally agree, and yeah, "you eventually memorize all the arcane bits" definitely isn't a point in favor of powershell

there are also some commands I use all the time that don't have built in aliases like the json converters, so that makes cross-machine alias consistency for some important things not great

I think the long form is because people usually tab to complete the names. Personally once you learn them they dont get that hard to type
It's just a knee-jerk reaction people have in any thread where powershell is mentioned. "Hur hur long command names." Doesn't bring anything to the discussion.
I can see where you're coming from, but to me it's not some meme or joke. I find it similarly annoying in Java, for example, and it makes me want to use that language less. Obviously it's only a small part of the whole consideration.
Every common command has a short alias, or often multiple short alias. Get-ChildItem => "ls", "gci". Get-Content => "gc", "cat". These aliases are standardized, you can look them up with Get-Alias (or "gal" ;) ).

It means that working in the terminal, you can use short commands, and when you write a long-term script, you use the long names so that the script is more readable.

What I find great is that flags also have aliases that are standardized across commands.

This is why I'm annoyed at this meme. It just stems from ignorance.

What’s long in Java? It sure longer than the absolutely insane C convention of snrcph whatever, but these AbstractFactoryFactory things are just memes - the Java convention is to prefer full words, but that’s the same in I believe the majority of languages - JS, Rust, Python all use basically identical names, at most casing differs.
I assume you similarly also find Apple's swift/objc API's annoying. (If not, might want to objectively evaluate bias)
Yeah, it can definitely be kind of a meme, but also I've never had a bad time bringing it up in good faith. A lot of people don't even realize it's a knee-jerk meme response to them. OP also doesn't seem to just be MS bashing, and I think there's a reality that the typical linux/macos dev just doesn't have a compelling reason to sink time into vetting PS, whereas I had a reason to learn it and ended up really digging it.

But I do get what you're saying and think it's a common meme that's often unhelpful

It doesn't bring anything new to the discussion, but if it is the reason people don't use it, then it is relevant.

I don't use it, because I was Mac/Linux at home and Linux at work for so long - only now do I have a reason to.

I think that's important, tbh

I love powerful. I've used it for a long and even though I primarily work on macos/linux now, I install powershell core on everything.

That said, I _started_ using it because I was working on a windows box doing C# and managing windows servers.

There's just not a compelling reason for a dev to learn it outside of personal interest, and I think that's a completely legit mindset, since we all have limited time. I'm even fine with misconceptions--we all have them about something--as long as the person is being a decent human about it (which is why I've enjoyed this thread/comments)

It has its benefits, other people's scripts are very readable, and often you can just guess the correct command without having to look anything up.
Even with the default short aliases like gci there are only ~100 unique commands/commandlets aliased and 600 commandlets in a default install. Not to mention what happens when you start loading other commandlets. Trying to predicate your usage of PS on just using short commands is also going to fall short in documentation and searches. I recommend just getting used to the fact command names are long. <tab> is a good friend too.
Often mentioned failing of powershell commands is that they went with Verb-Noun, when the reverse would have been much more discoverable. You want to specify what you want to operate on first, Get-<Tab> will be much less useful then Process-<Tab>.

Otherwise, despite their length I do like these long names, you can have aliases for ‘ls’ and alia, and flags fuzzy match.

Is there a Powershell script to disable adware on a windows 11 box ?
lol, you know what's funny is that I actually used to have a script like that for windows 10.

I volunteered to help a local nonprofit image a bunch of laptops and they'd bought win 10 home licenses for something like 30 laptops. The whole thing was kind of a nightmare but got most of the adware stripped out, I think, but not all of it. been awhile, so hard to remember