Live data from Hacker News

Linux Bash vs. Windows PowerShell

vedipen.com

81–90 of 93 posts

Re: Linux Bash vs. Windows PowerShell

#81
post #61

The article does need a lot more fleshing out. As many have said here the thing that powershell has over bash is piping objects.

That presumes, which is always my complaint about this subject, that this is an advantage. I'd say that's what sh, ksh, and bash have over powershell (tm). The problem with pipelines of objects is that it is inherently a more strongly typed, defined, interface. And therefore special-case. Streams of characters is as loosely typed as it gets. And for processing text files and gluing disjointed tools together, it may s…

>The problem with pipelines of objects is that it is inherently a more strongly typed, defined, interface. And therefore special-case.

Not true. While I am somewhat of a novice at powershell, I didn't find that to be the case at all.

> Streams of characters is as loosely typed as it gets. And for processing text files and gluing disjointed tools together, it may seem crude, but is very effective. Especially for quick text processing jobs, or automating series of commands.

Well done for the Pavlovian regurgitation of how piping text output is supposed to work.

I don't like working with it. It is okay for small scripts. However if it is mildly complicated I would use something like Python (not powershell).

Powershell is great for small scripts where you need to do sysadmin tasks e.g. I have a script where I setup my SQL Database aliases for development. Piping text about doesn't help me in these sorts of tasks. I need to go "I need to find where the real database is, and then map those properties to an alias". That works better with piping objects. It works kinda like functional concepts such as map(), reduce() etc.

You should use the right tool for the right job.

> The UNIX shell concept has been honed and refined over 50 years to do exactly what it does, and it does it very well. It is also extremely generic. This choice was on purpose and has stood up well to the test of time.

You know not everyone thinks that Unix was the pinnacle of human achievement.

Re: Linux Bash vs. Windows PowerShell

#82
post #61

Earlier quoted context omitted.

That presumes, which is always my complaint about this subject, that this is an advantage. I'd say that's what sh, ksh, and bash have over powershell (tm). The problem with pipelines of objects is that it is inherently a more strongly typed, defined, interface. And therefore special-case. Streams of characters is as loosely typed as it gets. And for processing text files and gluing disjointed tools together, it may s…

>The problem with pipelines of objects is that it is inherently a more strongly typed, defined, interface. And therefore special-case. Not true. While I am somewhat of a novice at powershell, I didn't find that to be the case at all. > Streams of characters is as loosely typed as it gets. And for processing text files and gluing disjointed tools together, it may seem crude, but is very effective. Especially for quick…

I'm not saying UNIX and similar system are even the pinnacle of potential operating systems. But they're pretty darn good, and at least at par with, when compared to other existing mature ones.

> You should use the right tool for the right job.

Agree. UNIX however, has a fundamental file and character based structure. Windows, the opposite. So while powershell and its predecessors are useful in that environment, it's not equally suited to the tasks that bash is used for.

So what I'm poking at is that while bash isn't a great tool for interfacing with the service manager, or registry, or policy frameworks and the like (SQL, definitely), powershell is not a general purpose command processor and text manipulator. And on UNIX, whether you like that philosophy or not, that's all you need. I would never want to use a powershell script to move and rename file structures with some rules and variables.

> It is okay for small scripts.

That's what it's designed for and how it should be used. If you are talking about libraries or even a lot of functions, or if it's thousands of lines long, other more formal programming languages like Python (and with good debuggers) would be better. But to just bang out an adduser script in 30 minutes, that's where shell is lightweight enough to really shine.

Look, typed OO pipelines sound like a good idea, but the negative side is this. For example, to deal with the registry, you have to have purpose built library like https://docs.microsoft.com/en-us/powershell/module/microsoft... that someone needs to write and then everyone has to know. This has to be done for every kind of interface in windows. This is just as complex as Pythons standard libraries or writing C or C++ Win32 code.

With the UNIX toolkit philosophy, I have about 20 utilities and builtins to know: shell + awk/grep/sed/cut/etc. And that's it. The cons are #1 efficiency is lower and #2 as pointed out by many folks, a lot of scripts spend a lot of code inline (in different ways) things like how to parse a config file.

But back to the article. It's not valid to just presumptively state like a fact that one is better than the other as the argument. And it's really not valid to compare such different tools head-to-head when it's the whole underlying philosophies of their associated ecosystems that are so different.

Re: Linux Bash vs. Windows PowerShell

#84
post #82

Earlier quoted context omitted.

>The problem with pipelines of objects is that it is inherently a more strongly typed, defined, interface. And therefore special-case. Not true. While I am somewhat of a novice at powershell, I didn't find that to be the case at all. > Streams of characters is as loosely typed as it gets. And for processing text files and gluing disjointed tools together, it may seem crude, but is very effective. Especially for quick…

I'm not saying UNIX and similar system are even the pinnacle of potential operating systems. But they're pretty darn good, and at least at par with, when compared to other existing mature ones. > You should use the right tool for the right job. Agree. UNIX however, has a fundamental file and character based structure. Windows, the opposite. So while powershell and its predecessors are useful in that environment, it's…

> So what I'm poking at is that while bash isn't a great tool for interfacing with the service manager, or registry, or policy frameworks and the like (SQL, definitely), powershell is not a general purpose command processor and text manipulator. And on UNIX, whether you like that philosophy or not, that's all you need. I would never want to use a powershell script to move and rename file structures with some rules and variables.

I can manipulate text fine with Powershell without having to use other small programs that may or may not exist on the system. I can also interface with parts of the operating system sensibly. I was reading and writing text files a lot easier with Powershell than I ever did with Bash.

> Look, typed OO pipelines sound like a good idea, but the negative side is this. For example, to deal with the registry, you have to have purpose built library like https://docs.microsoft.com/en-us/powershell/module/microsoft.... that someone needs to write and then everyone has to know. This has to be done for every kind of interface in windows. This is just as complex as Pythons standard libraries or writing C or C++ Win32 code.

You seem to think that this is somehow a negative. I think you should be able to rely on an abstractions. I would rather rely on a well defined and understood interface than writing my own script to manipulate a file. The former is obviously less error prone than the other. Any claim to the contrary is a nonsense.

> But back to the article. It's not valid to just presumptively state like a fact that one is better than the other as the argument. And it's really not valid to compare such different tools head-to-head when it's the whole underlying philosophies of their associated ecosystems that are so different.

Yes one is sane and the other one isn't. I've heard most of these (bogus) arguments before. I hate to sound rude, but I honestly fed up of hearing it.

Re: Linux Bash vs. Windows PowerShell

#85
post #30

Earlier quoted context omitted.

PowerShell takes some time to grok, but once you get it it has very deep integration with Windows systems, and can become a joy to work with. That being said, I still feel violated every time `ls` returns `bad command or filename`

Are there different versions of PowerShell? 'ls' has always worked for me. 'ls -al' does not however, and that does feel a bit violating.

`ls` is an alias on windows systems. I dont remember what the command maps to, but it maps to something. Same thing with a lot of others (e.g. cat is an alias for Get-Content)

Re: Linux Bash vs. Windows PowerShell

#86

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…

It would be nice if PowerShell had object serialization and deserialization functions built into the language or standard library, similar to the Common Lisp read and print functions. This would make it possible for PowerShell to interoperate with other command line facilities.

Does `ConvertTo-Json` and `ConvertFrom-Json` not handle what you want?

Re: Linux Bash vs. Windows PowerShell

#87

Earlier quoted context omitted.

It would be nice if PowerShell had object serialization and deserialization functions built into the language or standard library, similar to the Common Lisp read and print functions. This would make it possible for PowerShell to interoperate with other command line facilities.

Does `ConvertTo-Json` and `ConvertFrom-Json` not handle what you want?

Awesome. Thank you for letting me know about those. I have been using bash and Perl for many years, but have only dabbled in PowerShell since almost all of my work happens on Linux.

I am bookmarking those because I expect to have to use PowerShell for some automation tasks on Windows in the near future.

Re: Linux Bash vs. Windows PowerShell

#88
post #82

Earlier quoted context omitted.

I'm not saying UNIX and similar system are even the pinnacle of potential operating systems. But they're pretty darn good, and at least at par with, when compared to other existing mature ones. > You should use the right tool for the right job. Agree. UNIX however, has a fundamental file and character based structure. Windows, the opposite. So while powershell and its predecessors are useful in that environment, it's…

> So what I'm poking at is that while bash isn't a great tool for interfacing with the service manager, or registry, or policy frameworks and the like (SQL, definitely), powershell is not a general purpose command processor and text manipulator. And on UNIX, whether you like that philosophy or not, that's all you need. I would never want to use a powershell script to move and rename file structures with some rules an…

> Yes one is sane and the other one isn't

Agreed! Clearly you mean UNIX/Linux is the sane one, right? Before you fly into a hissy fit and say the UNIX toolkit theory is insane please learn, read, and respect a little history. So all the famous papers, IEEE, ACM, written by folks like DMR and Thompson are "bogus" arguments, right???

These guys might have done things in ways you don't grok, ways you don't like, or ways you think you know how to do better. The UNIX approach, like all complex things, has pros and cons. But until anything you or microsoft has built has stood up for 50 years, been academically published and cited, maybe won a couple Turing awards and Presidential medals, don't try defend an argument with a simple "it's bogus" or "insane" or "nonsense".

Re: Linux Bash vs. Windows PowerShell

#89
post #88

Earlier quoted context omitted.

> So what I'm poking at is that while bash isn't a great tool for interfacing with the service manager, or registry, or policy frameworks and the like (SQL, definitely), powershell is not a general purpose command processor and text manipulator. And on UNIX, whether you like that philosophy or not, that's all you need. I would never want to use a powershell script to move and rename file structures with some rules an…

> Yes one is sane and the other one isn't Agreed! Clearly you mean UNIX/Linux is the sane one, right? Before you fly into a hissy fit and say the UNIX toolkit theory is insane please learn, read, and respect a little history. So all the famous papers, IEEE, ACM, written by folks like DMR and Thompson are "bogus" arguments, right??? These guys might have done things in ways you don't grok, ways you don't like, or ways…

> Agreed! Clearly you mean UNIX/Linux is the sane one, right? Before you fly into a hissy fit and say the UNIX toolkit theory is insane please learn, read, and respect a little history. So all the famous papers, IEEE, ACM, written by folks like DMR and Thompson are "bogus" arguments, right???

Seems you are going into the hissy fit. I also don't care about your arguments from authority. Programming against a well defined abstraction will be better than piping things around and easier for people to understand.

> These guys might have done things in ways you don't grok, ways you don't like, or ways you think you know how to do better. The UNIX approach, like all complex things, has pros and cons. But until anything you or microsoft has built has stood up for 50 years, been academically published and cited, maybe won a couple Turing awards and Presidential medals, don't try defend an argument with a simple "it's bogus" or "insane" or "non

This is the Pavlovian response to any criticism of the great unix way. Again all of this is an argument from authority and people used Unix because it was good enough and available. Lets not pretend it was successful because it was so great.

Re: Linux Bash vs. Windows PowerShell

#90
post #88

Earlier quoted context omitted.

> Yes one is sane and the other one isn't Agreed! Clearly you mean UNIX/Linux is the sane one, right? Before you fly into a hissy fit and say the UNIX toolkit theory is insane please learn, read, and respect a little history. So all the famous papers, IEEE, ACM, written by folks like DMR and Thompson are "bogus" arguments, right??? These guys might have done things in ways you don't grok, ways you don't like, or ways…

> Agreed! Clearly you mean UNIX/Linux is the sane one, right? Before you fly into a hissy fit and say the UNIX toolkit theory is insane please learn, read, and respect a little history. So all the famous papers, IEEE, ACM, written by folks like DMR and Thompson are "bogus" arguments, right??? Seems you are going into the hissy fit. I also don't care about your arguments from authority. Programming against a well defi…

You love the word Pavlovian don't you?

I'm not making an argument to authority. I'm saying you are dismissing, without any valid argument at all, years of reasoned academics and experienced and careful engineering.

So what's your argument? You're level abstract is "better" because it just clearly is. And you're tired of hearing another viewpoint?

I think you are very naive and I don't see you how will gain experience if you don't wish to listen to anything you don't already understand!

Post reply on HN