Live data from Hacker News

In defense of PowerShell

benwilson.me

81–82 of 82 posts

Re: In defense of PowerShell

#81

Earlier quoted context omitted.

I've lived in both the windows and linux/unix worlds and I will say that powershell is a better scripting language than bash. Bash is ok, but powershell is nicer. Powershell is sort of like python in that it tends to force down a path of doing things in a certain way. Powershell isn't just "more tools and glue for windows stuff", it's a different way of doing things. In powershell you get named command-line parameter…

I'm not sneering at PowerShell because it's not Linux. And I think it's an impressive model. It's certainly a different way of doing things, and it's worth looking at and learning from. But Powershell people dismiss the bash and Linux model of "everything's a file", too, the same way others dismiss the Powershell model. They're different; neither is "unquestionably" better for all cases. Personally, once I start want…

Personally I think an interactive shell that works well with objects is incredibly valuable. I love working in PowerShell and I wish there was a good Python based shell that I could use to replace zsh. I spend a lot of time in iPython but it's not quite the same.

Re: In defense of PowerShell

#82
post #62

I started off as a PowerShell fan, but my introductory experience has been pretty poor. A little while back, I tried testing the output of a sorting algorithm with PowerShell. I wrote a line of bash to check my results: diff Then I wrote the PowerShell: get-content output.txt | foreach-object { [Int] $_ } | sort-object | out-file -encoding ascii sorted.txt compare-object (get-content output.txt) (get-content sorted.t…

AFAICT, you are just trying to check if a file is sorted? Then wouldn't: diff (cat out.txt | sort | out-string) (cat out.txt -raw) do it?

Yeah, actually. Though, I'd still include the cast to int, because I need to sort numerically, not lexicographically.

I suppose the lesson is that if you want to preserve line order, you need to use -raw to prevent Get-Content (cat) from splitting the file into multiple lines. That still ruins the output text from Compare-Object (diff), but it's cleaner than fc.exe.

Thanks.

Post reply on HN