Live data from Hacker News

Linux Bash vs. Windows PowerShell

vedipen.com

51–60 of 93 posts

Re: Linux Bash vs. Windows PowerShell

#51
post #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 ju…

It very much is documented.

    Get-Help about_Redirection
Received wisdom about Write-Host, by the way, is that one rarely wants it.

Re: Linux Bash vs. Windows PowerShell

#53

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…

> 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.

The costs of doing this don't get enough mention though. You're essentially locking yourself into an ecosystem.

It's typical in bash to have a pipeline where every program is written in a different language -- shell scripts, Python, C, C++, Rust etc. They can all operate on text, but what is a Python program supposed to do with a Rust object or vice versa?

It only works between two programs that support the same object format. But in that case you're effectively passing an object to a function in the same language. Languages already have that with lower overhead than pipes. Even if you're set on using pipes, nothing really stops you from piping a binary format object from one program to another, as long as they use the same object format.

So I think the people who say to compare PS to python and not bash are right, but it's not even that -- just compare it to any other language that has objects. It can pass the objects easily within the language but not outside of it. That's hardly a novelty. And then, despite the ostensible ports to other platforms, you have the usual drawbacks of vendor-specific languages -- many of the APIs only exist or do something useful on Windows and you're locking yourself into the platform.

Re: Linux Bash vs. Windows PowerShell

#54

Earlier quoted context omitted.

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.

Yes, because they do much less than the shell version Here is a shell version which does the same thing as python, it is much smaller as well:

https://github.com/realrasengan/autobahn/pull/8/files#diff-6...

Re: Linux Bash vs. Windows PowerShell

#55

Earlier quoted context omitted.

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"

PowerShell Core is cross-platform. It runs on Mac, Linux and Windows.

Re: Linux Bash vs. Windows PowerShell

#56

Earlier quoted context omitted.

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.

Thank you gabrielsroka!

Re: Linux Bash vs. Windows PowerShell

#57
post #47

Earlier quoted context omitted.

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.

I agree, and I see that you posted a better comparison with hn.sh! Thank you so much theamk!

Re: Linux Bash vs. Windows PowerShell

#58

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…

> 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. The costs of doing this don't get enough mention though. You're essentially locking yourself into an ecosystem. It's typical in bash to have a pipeline where every program is written in a different language -- shell scripts, Py…

Sure, but my understanding is that PowerShell by itself can do alot of the stuff I typically use four or five pipes to accomplish (e.g. `grep regex myFile | sort -u | cut -d ',' -f 3`). In which case, it might not be as much of a problem for most use-cases.

Re: Linux Bash vs. Windows PowerShell

#59
post #21

Earlier quoted context omitted.

Powershell is more for administrative automation

Same, unless you are on windows only, ps has no benefit. The selling point of ps is the piping of objects. Mac and linux api don't output those.

PowerShell is built on top of .Net Core, which is also cross-platform.

It does pipe objects on all 3 platforms.

Re: Linux Bash vs. Windows PowerShell

#60

Earlier quoted context omitted.

> 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. The costs of doing this don't get enough mention though. You're essentially locking yourself into an ecosystem. It's typical in bash to have a pipeline where every program is written in a different language -- shell scripts, Py…

Sure, but my understanding is that PowerShell by itself can do alot of the stuff I typically use four or five pipes to accomplish (e.g. `grep regex myFile | sort -u | cut -d ',' -f 3`). In which case, it might not be as much of a problem for most use-cases.

Sure it can, but so can one python script. For that matter, so can the four or five pipes. What's so wrong with `grep regex myFile | sort -u | cut -d ',' -f 3` etc.?
Post reply on HN