Live data from Hacker News

Linux Bash vs. Windows PowerShell

vedipen.com

41–50 of 93 posts

Re: Linux Bash vs. Windows PowerShell

#41

I dev on a Mac and do a lot of 'quality of life' scripting with Bash. I recently had to do something on a PC and figured I'd try out Powershell. I have to say, it was a joy. Dealing with objects instead of text is so refreshing, it really is a game changer especially when you start integrating with COM (e.g. excel). The only things I found worse: 1 - error handling doesnt bubble in the same way. e.g. I can't do an eq…

The equivalent to `set -e` is setting the `ErrorActionPreference` variable to "Stop" - all errors become terminating.

Re: Linux Bash vs. Windows PowerShell

#42
post #31

I hate how long the PowerShell comand names are. Yes they are sensible but arg. Eg grep vs Select-String as the article mentions.

Select-String is alisased to sls and if you are writing a one-liner or using it from shell - just use the alias.

It is recommended that you use full names in scripts for readability reasons so most script examples on the web have those long obnoxious names.

Also, tab completion works really well with command argument names so in practice it's not that many keystrokes.

Re: Linux Bash vs. Windows PowerShell

#43
post #23
post #9

I think PowerShell doesn’t really compete with Bash, it competes with Python, Perl or the like. And I haven’t found it to be superior in that aspect other than at integration with Windows system stuff.

PowerShell should raise the bar for lowest common denominator of scripting on Windows systems. I've dabbled a bit it, but I was disappointed it was so tightly coupled (possibly by necessity?) with the .NET runtime version. This makes it much more difficult to update on old systems. I had to write PowerShell in the oldest compatible version. It's almost like dealing with JavaScript implementations of all versions if I…

> Does PowerShell have a universally available package manager

It does, called OneGet and recently rewritten.

You can also use chocolatey.

For windows update: https://www.powershellgallery.com/packages/PSWindowsUpdate/2...

Re: Linux Bash vs. Windows PowerShell

#44

If you need crossplatform scripting and will install a runtime, why go powershell or bash ? Something like ruby or python seems more adpated.

Its designed for shell usage, python, ruby and friends don't feel "native" in that manner and are simply akward for many cases by missing most improtant thing - pipeline. People use them because bash suck and because they want to be full stack. Besides, Powershell comes with OS.

Keyword is "crossplatform"

Re: Linux Bash vs. Windows PowerShell

#46
The biggest issue in PowerShell is very slow script execution startup time, 300-500ms seems to be typical. So forget about externally launching PowerShell scripts thousands of times.

The second biggest issue I've seen is generic lack of robustness and maturity. Default cmdlets do the common case nicely, but once you have something unusual in the mix things go wrong fast... By unusual, I mean things like filesystem junctions, volumes mounted into directories.

If you want colors, Write-Host is nice. Except that it goes only to console AND to (undocumented?) file id 6! (same way like stdout goes to 1, stderr to 2, etc.).

PowerShell seems to behave slightly differently in each Windows version. A script that's written for Win10 1803 might just break under 1809.

I don't have much issues with Bash etc., even sh. It performs well and is very robust. I do hate its many footguns, like how easy it is to get escaping wrong.

Re: Linux Bash vs. Windows PowerShell

#47

Article might be more successful if it demonstrated some of the advantages of PowerShell, such as returning the output as objects instead of lines, and what you can do with them as a result. I'll admit to being in the "Bash is what I know, I'll just install WSL/Cygwin/PuTTY on my Windows workstation and be done with it" crowd. PowerShell is on my bucket list of things I need to learn at some point, or at the very lea…

I made a Bash script for HN, and while I’m the furthest thing from an expert in Bash (I’m a newb), I was impressed by a contribution made with a port of the script to Powershell[1]. You can see the same script compared in Bash, Powershell and Python! Prior to this I had never really explored PS, but it is definitely cool Shameless Plug: [1] https://github.com/realrasengan/autobahn

This seems pretty unfair to bash - bash version is way longer than needed, both because it does more (more fields, difference tracking) and because it is written very vebosely (very long prefixes on each var, using multiple calls instead of single “read” command)

I really dislike those comparisons where one side wins not because the language is better, but because it does much less.

Re: Linux Bash vs. Windows PowerShell

#48
post #23
post #9

I think PowerShell doesn’t really compete with Bash, it competes with Python, Perl or the like. And I haven’t found it to be superior in that aspect other than at integration with Windows system stuff.

PowerShell should raise the bar for lowest common denominator of scripting on Windows systems. I've dabbled a bit it, but I was disappointed it was so tightly coupled (possibly by necessity?) with the .NET runtime version. This makes it much more difficult to update on old systems. I had to write PowerShell in the oldest compatible version. It's almost like dealing with JavaScript implementations of all versions if I…

PowerShell Core should solve that problem, as you can ship it with its own .NET Core runtime.

Re: Linux Bash vs. Windows PowerShell

#50

Article might be more successful if it demonstrated some of the advantages of PowerShell, such as returning the output as objects instead of lines, and what you can do with them as a result. I'll admit to being in the "Bash is what I know, I'll just install WSL/Cygwin/PuTTY on my Windows workstation and be done with it" crowd. PowerShell is on my bucket list of things I need to learn at some point, or at the very lea…

I made a Bash script for HN, and while I’m the furthest thing from an expert in Bash (I’m a newb), I was impressed by a contribution made with a port of the script to Powershell[1]. You can see the same script compared in Bash, Powershell and Python! Prior to this I had never really explored PS, but it is definitely cool Shameless Plug: [1] https://github.com/realrasengan/autobahn

Thanks rasengan. I've been using PowerShell for about 5 years now. I was trying to learn Bash, but I found too limiting -- it was like going backwards. So, I started learning Python.

You'll notice that the PowerShell and Python versions are very similar.

Post reply on HN