7 ms·
I think the reason I've been avoiding Powershell is specifically the pattern of `Verb-Noun -Option argument` the author brings up. I'm not saying it's not "bet
by bszupnick 6y ago
I think the reason I've been avoiding Powershell is specifically the pattern of `Verb-Noun -Option argument` the author brings up.
I'm not saying it's not "better" (however you measure that) but I think it's very wordy and that's always been a turn-off and barrier of entry for me.
some examples:
pwd --> Set-Location
ls --> Get-ChildItem
cp --> Copy-Item
I totally understand how bash's sometimes seemingly random shortcuts or acronyms can ALSO be a huge barrier of entry (just as it was for me!) and the straightforwardness of Powershell is a lot clearer, but personally now that I'm "in" on the short-hand of bash, it's been hard to start using Powershell.
- meragrin_ 6y agoThat's what aliases are for. All three examples are there by default for me as aliases.
- axiomdata316 6y agoI'm not sure if this is relevant but I tried all three of the Linux commands in Powershell and they worked as well.
- NikolaNovak 6y agoWordiness for some interesting reason makes it HARDER for me to remember stuff. Kind of like I struggled with PMP exam and memorization because "Integrated Change Control Management" became "Controlled Management Change Integration" or "Managed Variation Integration" or whatever in my mind, "Retrieve-Child-Item" vs "Get-ChildItem" or "Send-Command" vs "Invoke-Command" "Remove-Tiingamajiggy" vs "Delete-Whatchamacallit"... my mind is seemingly better equipped to memorize "obscure but unique" gobbledygook rather than "meaningful-but-generic" verbiage :|
- adzm 6y agoI had the same experience, though eventually just having more practice with powershell it ends up second nature. Especially with the ides and completion that can come with it.
- xorcist 6y agoPerhaps PowerShell is the new COBOL?
- NikolaNovak 6y agoHah, I was thinking of that... I did have to code in COBOL for 6 months in ~2000 and I see some similarities in syntax paradigm (though superficial of course) - but I figured the reference would be too obscure for majority of HN audience :->
- marcosdumay 6y agoThe rigid and obscure syntactic structure also checks. It's a couple of hours task for me to define a function, mostly spent on debugging the definition. (Probably, if I did it all the time, I'd get it right every time. Just like creating and using COBOL variables.)
- Izikiel43 6y agoI have the same problem with bash. I have spent hours trying to write a simple function which in PS would have been 10 minutes.
- marcosdumay 6y agoYou mean writing the function body? I was not talking about the function body, but about getting the declaration correct. (The bad error messages and lack of real time verification surely contribute here.) PS is more powerful than Bash, it really should be faster to write a function body in it.
- userbinator 6y agoIndeed, I have the same reaction to Powershell syntax as I do Enterprise Java and C# --- extremely verbose and hard to actually read beyond the surface --- the fact that it contains English words is in some ways deceptive. The mixed case Reminds Me Of People Who Always Write Like This, and that's as annoying as it looks. My theory of why it is harder to read is because longer sequences of characters are harder to memorise than shorter ones.
- sterlind 6y agoFwiw, those aliases you mention all exist. I always do "ls" and "cd" for example. But what really annoys me is that there's no aliases for arguments. So "find . -name foo" becomes "ls -Recurse -Include foo" which makes my carpal tunnel just a little worse. It's a shame because the rest of Powershell is so good.
- Tarean 6y agoFor commands you use frequently you can still use shortforms, positional arguments, and tab completion, though. For instance in powershell you can also do: ls -r foo
- stinos 6y agothere's no aliases for arguments There are (if implemented by the function), and moreover you can use just shrink the name to the point it becomes ambiguous. Your example is the same a "ls -r -i foo". Also tab completion. You never type those out in full, no carpal tunnel, it's just "l -r" the TAB and select what you want. Discoverability is everything in PS.
- ygra 6y agoThere are aliases for parameters, `-ea` for `-ErrorAction` comes to mind. But those are defined by cmdlets, not the user. However, you can always shorten parameter names as long as they remain unambiguous with other parameters, so Get-ChildItem -Recurse -Include foo would become ls -r -i foo which just happens to be shorter than your 'find' example.
- vips7L 6y agoPowershell is smart enough to find the argument as long as it's not ambiguous. For instance: Remove-Item -r -fo ./path/to/some/directory Powershell is smart enough to know that -r means -Recurse and -fo means -Force because the Remove-Item cmdlet has no other parameter that starts with -r. For -f there are two possible arguments: -Filter and -Force which is why you need to be more specific with -fo.
- voodootrucker 6y agoThough I definitely agree that bash's abbreviations are a barrier to entry, I think a bigger impediment not just with bash but many languages (say, Haskell) is ungooglable operator syntax. If you didn't know what it was, how would you figure out what `$(expression)` means in bash for example?
- sbelskie 6y agoYea, in that case I just search “bash operators” and hope to find a page that includes an example of the one I’m trying to understand.
- marcosdumay 6y agoI think this one is called a "type of quote", not "operator". At least Bash has a very complete man-page, you can just search for `$(` there and you'll find it. But the Bash symbols all have different functions, there are (very few) operators, quotes, variables, and probably more than I can remember.
- travv0 6y agoHaskell has https://hoogle.haskell.org/ https://hoogle.haskell.org/ which lets you search functions named by symbols, function signatures, etc.
- tck42 6y agobash syntax is terse enough that it's practical at the interactive command line. Thus once you take it up, you take it up for scripts AND daily interactive use. For system operators who use both frequently, between these two you quickly internalize the abbreviations. I can see it being an issue for infrequent users. While it's not terrible, I find powershell pretty frustrating. I started off enthusiastic, especially given how archaic cmd.exe is. As mentioned elsewhere though, the advice not to use aliases, coupled with unbelievably long command names that I hate typing and can't always recall exactly - is it convert-to-csv? to-csv? no it's convertto-csv - I can never remember and I don't feel I should need to use ISE to work around this. This utterly prevents me from internalizing. Even worse, until v3 apparently, iterating over an empty array would fail out (iterate once on $null instead of not iterating at all) and had to be protected with an explicit check. I was on v2, and it was at this point that I completely checked out and decided it wasn't worth learning and that I'd wasted my time. In general I could do what I needed with either cygwin or win32 cpython and those didn't make me feel like clawing my own eyes out. It seems the situation has improved, but I just don't see any reason to take it up again, ESPECIALLY on linux, unless I _have to_ do dotnet stuff, and even if I do I'll explore every other available option first (ironpython? f#? is there a dotnet tcl?) TBH I avoid dotnet anyways given Microsoft's past (EEE) and current (telemetry, start menu ads, etc) behavior. Fool me once etc etc etc.
- BoiledCabbage 6y agoThe single most underused command in powershell is: Get-Alias Essentially every command you'd use has a 2 or 3 character alias that is easy to remember and quick to type. On top of it their almost programitacilly named, so if you know the powershell commands full name you can almost certainly guess the alias Typing Get-Alias lists them all out. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-alias?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/module/microsoft...
- dubcanada 6y agoThen you just end up with bash commands again, such as "pwd" and "cat"
- tremon 6y agoAliases don't have short forms for their arguments, so for any serious command you'd still be typing (tabbing) a lot.
- vips7L 6y agoYes they do. Powershell is smart enough to find the argument as long as it's not ambiguous. For instance: Remove-Item -r -fo ./path/to/some/directory Powershell is smart enough to know that -r means -Recurse and -fo means -Force because the Remove-Item cmdlet has no other parameter that starts with -r. For -f there are two possible arguments: -Filter and -Force which is why you need to be more specific with -fo.
- jxy 6y agoCommonly used terms/functions tend to become shorter and symbolized as some notation, similar to how all the Math notation came to be. A mathematician would be unproductive without those shorthand notations. But I guess there is a balance. Not everyone want to write matrix multiplications as A+.×B, though A%*%B seems acceptable to some, most nowadays write it as np.dot(A,B).
- alexfrydl 6y agoAll of those are aliased to the Linux commands and also have their own abbreviations (get-childitem -> gci).
- chousuke 6y agoIt also doesn't help that by default (at least in my experience), Powershell's tab completion is slow and annoying to use. I don't know if it's technically inferior, but it feels terrible. It does the thing where you get to cycle through various options instead of completing to the longest common prefix, which is really hard to get used to after years and years of interfaces that do the other thing. It's also difficult to form a repertoire of common shortcuts over time because so many commands share a prefix, so most often the shortest you will be typing is 5-6 characters before you get to anything unique.
- WorldMaker 6y agoThe defaults come out of old CMD.EXE (bad) habits, so so yes are missing like a dozen years of Linux terminal UX experimentation/improvements. One particularly common advice with Powershell is to try PSReadLine for more bash-like versions of tab completion and other line editing things: https://github.com/PowerShell/PSReadLine https://github.com/PowerShell/PSReadLine As for common shortcuts, as mentioned elsewhere in this thread, Get-Alias (and Set-Alias) is a very useful tool.
- jodrellblank 6y ago> "It does the thing where you get to cycle through various options instead of completing to the longest common prefix, which is really hard to get used to after years and years of interfaces that do the other thing." So change it: Set-PSReadLineKeyHandler -Chord Tab -Function Complete "Bash style completion (optional in Cmd mode, default in Emacs mode)" - https://docs.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/module/psreadlin...
- yakubin 6y agoMore importantly, when you have to adhere to the "Generic Verb-Generic Noun" pattern, the namespace fills up quickly and now creating a new program and sharing it is stifled by two problems: 1. coming up with a name that won't clash with others in already-extremely-limited namespace 2. marketing of a generically-named thing. In the Unix world, let's take top. After top came htop. How would that play out in the Powershell world? List-Processes -> SuperDuperList-Processes?
- hobs 6y agoPowershell recommends a module prefix https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_modules?view=powershell-7.1#how-to-import-a-module https://docs.microsoft.com/en-us/powershell/module/microsoft...
- jodrellblank 6y ago> "when you have to adhere to the "Generic Verb-Generic Noun" pattern" a) it's GenericVerb-SpecificNoun usually with a name at the front of the noun like Get-YakubinComments, and you don't /have/ to adhere to it. b) there isn't a single namespace, you can use the full name style Microsoft.PowerShell.Core\Get-Command if you want to disambiguate namespaces. c) You can `import-module -prefix ZZ` and then all commands in that module will get your prefix at the start of the noun part, like Get-ZZYakubinComment to avoid clashes. > "How would that play out in the Powershell world? List-Processes -> SuperDuperList-Processes?" No because List- isn't a standard verb, nor is SuperDuperList. Get-EventLog had Get-WinEvent added. Get-WmiInstance became Get-CimInstance. The third party NTFSSecurity module added a Get-Item2 to cover for Get-Item, and a Get-NTFSAccess to cover for Get-ACL. And because it's a shell and can run binaries, there's no problem with you having or running top and htop. or aliasing htop or calling your own thing htop, the Verb-Noun pattern isn't mandatory, it's recommended for companies developing modules so that administrators will have ideas how to list things, add things, remove things, without having to read the manual to find that it's mysterymgmtcli --auth-control -login-create instead of New-ToolUser.
- mjevans 6y agoNamespaces in a shell gives me all the bad vibes of XML namespaces.
- evad3r 6y agoAs others have said, aliases do exist, but I don't think you can deny that verb-noun makes learning Powershell a lot easier. For instance, if I want to get a user account, you know that Get-User exists. You can therefore also assume that Set-User also exists as a command. Tab completion helps a lot too with figuring out what options there are.
- Kuinox 6y agoPS C:\Users\Kuinox> pwd Path ---- C:\Users\Kuinox PS C:\Users\Kuinox> ls Directory: C:\Users\Kuinox Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2020-11-30 15:39 .android [private info redacted] PS C:\Users\Kuinox> Get-Alias cp CommandType Name Version Source ----------- ---- ------- ------ Alias cp -> Copy-Item Every command you listed are default alias in ps.
- jodrellblank 6y ago> "Every command you listed are default alias in ps." No, ls and cp are not aliases on Linux; the aliases which clashed too much with existing Linux commands were removed in PowerShell core, they only still exist on Windows. PS /> get-command ls,cp CommandType Name Source ----------- ---- ------ Application ls /bin/ls Application cp /bin/cp
- ur-whale 6y agoI that actual backslashes I spy in there? Jeezus.
- Kuinox 6y agoIt's on Windows, so yes, path are displayed with backslashes.
- heresie-dabord 6y agoMicrosoft may contribute to open source but not all contributions are good. Powershell breaks with every significant open-source language style and is therefore a typically bad investment of time for a non-Windows developer. MS technologies have sometimes been a bad investment for Windows developers too.
- majkinetor 6y agoThat is ridiculous. Please don't spread FUD.