News for hackers. Stuff that matters.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by qorrect on Sunday March 12, 2023 @03:46PM (#35125248)
Sorry but that looks terrible.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by jrumbut on Sunday March 12, 2023 @04:12PM (#35125602)
I 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.

Re:Nushell.sh ls | where size > 10mb | sort-by modified by Arnavion on Sunday March 12, 2023 @04:36PM (#35125929)
Blocks 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.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by marcosdumay on Sunday March 12, 2023 @04:51PM (#35126106)
> 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?

Re:Nushell.sh ls | where size > 10mb | sort-by modified by Arnavion on Sunday March 12, 2023 @05:14PM (#35126395)
Because 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.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by jrumbut on Sunday March 12, 2023 @04:59PM (#35126207)
Blocks 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.

Re:Nushell.sh ls | where size > 10mb | sort-by modified by justeleblanc on Sunday March 12, 2023 @04:35PM (#35125922)
Parentheses 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.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by Kwpolska on Sunday March 12, 2023 @03:55PM (#35125368)
What about it looks terrible? The braces are necessary, because this is a lambda.
Re:Nushell.sh ls | where size > 10mb | sort-by modified by doodlesdev on Sunday March 12, 2023 @03:59PM (#35125426)
I'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
Re:Nushell.sh ls | where size > 10mb | sort-by modified by vips7L on Sunday March 12, 2023 @04:14PM (#35125627)
You don’t need the lambda. Where-Object can just take the Length property.