5 ms·
- Better errors - Native support for JSON, etc (no more ConvertFrom-* ConvertTo-*) - Less verbose - Different visualisation
by operator-name 4y ago
- Better errors
- Native support for JSON, etc (no more ConvertFrom-* ConvertTo-*)
- Less verbose
- Different visualisation
- Kwpolska 4y agoPowerShell isn’t that verbose, compared to NuShell. The ls example would be (with standard PowerShell aliases): gci | where { $_.Length -gt (10 * 1024 * 1024) } | sort LastWriteTime -gt might seem weird, but it’s better than overloading >. (Also, I like the fact that PowerShell is built into Windows and has a large corporation behind it.)
- qorrect 4y agoSorry but that looks terrible.
- Kwpolska 4y agoWhat about it looks terrible? The braces are necessary, because this is a lambda.
- doodlesdev 4y agoI'd say that $_ is really weird and looks horrible. Also having to do (10 * 1024 * 1024) instead of just writing 10MB is a downgrade even compared to POSIX-compliant sh. In my other comment I've added a few examples in sh, zsh, and a better PowerShell example: gci | ? Length -gt 10MB | sort LastWriteTime
- deleted 4y ago[deleted]
- vips7L 4y agoYou don’t need the lambda. Where-Object can just take the Length property.
- jrumbut 4y agoI don't mind the looks but I find it hard to debug and have a poor instinct for "does this need a curly bracket or a parens?" That's my real issue with PowerShell, I find it very hard to predict what will work unless I know exactly what the rule is. Shell has similar issues but I've put 20 years into it so the knowledge is there. Every time the PowerShell people describe PowerShell I think "that sounds awesome" but the ergonomics don't work for me.
- Arnavion 4y agoBlocks always use braces. Expressions use parentheses for grouping sub-expressions. It's the same as many C-like languages. I can't imagine any situation where you would be confused which one you need to use.
- marcosdumay 4y ago> I can't imagine any situation where you would be confused which one you need to use. Why is that test returning a boolean on the GP a block?
- Arnavion 4y agoBecause it's an arbitrary piece of code that needs to be re-evaluated for every input item, like an inline function / lambda in other languages, not an expression that is evaluated once when the commandline is instantiated.
- jrumbut 4y agoBlocks always use braces, but sometimes you are passing parameters and other times you are passing a block. If I spent all day as a PowerShell dev I'm sure I would know it, but for something I reach for once or twice a year intuitiveness is a feature I would like to have.
- justeleblanc 4y agoParentheses are for grouping. Curly brackets are for creating a new script block. If you would have wanted to write "function foo() {}" in another language, go for curly brackets. It's really not that complex.
- doodlesdev 4y agoThe fact PowerShell has this masochistic tendency to have commands that start with capital case already makes it outside of the realm of consideration for me. It's absolute nonsense. Also I have to say your example is extremely confusing and would probably take quite a bit of time to write IRL. For reference, the equivalent in sh would be: find . -maxdepth 1 -type f -size +10M -exec ls -lt {} + Or a very terse example: du -s -h * | sort -r -h | sed 10q The thing is that if you're already used to POSIX-compliant shells then this is simply natural to write. Nushell has a different proposition of making it closer to natural language, which makes the learning curve much better. PowerShell just makes it different, but not really that much better. Also this is somewhat tangential, but I hate that PowerShell 5 and 7 are completely different things, and that PowerShell 5 is still the default even in Windows 11. Oh yeah, and just for lols this is the same thing in zsh: ls -lt *(.L+10240k) By the way, I should note that it's possible to make the PowerShell example much simpler like the following: gci | ? Length -gt 10MB | sort LastWriteTime The thing that really gets me here is the need to know aliases to keep it short, if you were to do it without the aliases it would look like this: Get-ChildItem | Where-Object { $_.Length -gt 10MB } | Sort-Object LastWriteTime Also, again, case-sensitive commands make me mad.
- vips7L 4y agoPowerShell isn’t case sensitive. Personally I prefer `where` over `?` though.
- justeleblanc 4y agoCommands aren't case sensitive. Just try it! Tab completion even works if you start the command lowercase. As for needing to know aliases... Did the knowledge that 'du' stands for 'disk usage' exist in your brain at birth, or did you have to learn it somehow? That criticism is nonsense. At least with powershell, commands have a canonical, explicit name with standard verbs and nouns; and a short alias that's equivalent to the initial command in every way. What I also like is that parameters have aliases too: you can write - WhatIf or -wi and it'll work the same. And everything is documented.
- shortrounddev 4y agols is an alias for Get-ChildItem in Powershell as well, btw