Hacker News new | ask | show | jobs
by roxtar 4239 days ago
>> It also has a totally different set of syntactic rules which aren't worth my time to learn.

>You're missing out. Powershell's syntax is quite intuitive after you learn the basics, you quickly start to be able to guess commands and params.

I have grown up using Unix tools and I am quite comfortable with them. If I have to learn a new shell and scripting language, there should be a demonstrable benefit for the time I spend learning it. Can you give examples where PowerShell can do something which CygWin/MinGw can't? Trying to understand why you say that I am missing out :)

2 comments

> Can you give examples where PowerShell can do something which CygWin/MinGw can't?

As those contain full programming languages which can effectively do anything with enough effort I doubt I can.

I will say the DateTime, cultural conversion, and email libraries are an absolute pleasure to work with in Powershell/.Net. Sending out email is a totally trivial exercise regardless of the style (plain text, HTML, attachments, etc).

http://technet.microsoft.com/en-us/library/hh849925.aspx

Thanks for the pointers and the link.
The main benefit of PowerShell over other shells is the object pipeline.

In classical shells, a pipe basically connects binary stdout -> binary stdin. A pipe between PowerShell cmdlets, on the other hand, can produce .NET objects directly without having to serialize them, so the pipe can connect .NET object producer -> .NET object consumer. If the consumer can't handle objects, the pipe degrades to binary stdout -> binary stdin.

For instance, the pipe in `ls | grep` is drastically different from `ls | fl`, because the latter is an in-process transfer of a .NET object collection, while the former transfers lines of text from one process to another, (in this case, to GNU Grep.)

Upside: the consumer doesn't have to "parse" stdin to get reasonable data on which it can operate.

Downside: if you want to write a consumer, you're stuck in .NET land. (Oh, how I wish I could write a consumer written in python that could advertise that it supports a specific object-oriented serialization on stdin! Then we could write a PowerShell stdin/stdout compatibility layer into python as a module... Alas, I'm guessing this task is reasonably hard.)

Oddly, I couldn't find a great readable intro to the topic, but this comes close: http://www.darkoperator.com/blog/2013/1/28/powershell-basics...

The main problem of object pipeline is that only software written .Net understands it. That means most of the utilities we are familiar with in the Linux world doesn't work with them.

And I don't want to find every .Net equivalent of the command I use in Unix systems. Perhaps all the coreutils have counterparts in Powershell, but for all the other third party ones I use, probably not.

> Downside: if you want to write a consumer, you're stuck in .NET land.

Powershell has access to the whole .NET features, meaning you can also expose DLL and COM objects into your Powershell session.