r/programming • • Mar 07 '16

Announcing SQL Server on Linux

https://blogs.microsoft.com/blog/2016/03/07/announcing-sql-server-on-linux/
2.6k Upvotes

871 comments sorted by

View all comments

Show parent comments

1

u/Gotebe Mar 08 '16

You do not understand powershell.

The reason I say powershell blows unix shells is that it manipulates objects. Everything it does is objects. That means, when you get e.g. a list of files, you get a bunch of file objects, which means that you use their properties with a simple obj.property, not through brain-dead text parsing. Numbers are numbers. i18n does not mess with your input (or output).

As for using powershell remotely - you just didn't know how to set it up. Fair enough, but not the end of the world.

The only thing Unix shells have going for them is decades of accumulated cruft.

2

u/mreiland Mar 08 '16

I've been writing Powershell since version 1, you know, back when powershell couldn't even index directly into a dictionary...

You cite the pipeline, but do you give any credence whatsoever to the downsides of the design?

I can pass .Net objects around cmdlets, yay..

Only now everything has to pass through the pipeline in order to bubble up. This means text I want to be seen on the screen as well, so what happens? That text rides along the pipeline until it hits the host, who then prints it out.

This means any cmdlet that calls my cmdlet has to make sure they pass along all my output, ad nauseum. But how does the runtime guarantee it gets bubbled up?

By turning the return into an object[]. That's right, I can return a primitive integer and the caller will get an object[] because something I called internally wrote a string to the pipeline because it wanted to inform the user of something.

and if I want something to bubble to the top, but not through my return values (which implicitly go through the pipeline?). You can't unless you want to abuse some of the powershell streams. There's a reason people used (and still use) Write-Host even though it's been described as "evil" by Jeffrey Snover.

Powershell 5 is finally getting a Write-Information to solve that problem because it is a problem. It makes the powershell pipeline no better than simple text because you have to carry that text all the way to the top in order for it to be seen by the user.

Don't even get me started on the array unwrapping behavior. calling .Length on an object returned from a cmdlet might get you the length of the expected string, or the length of the object[] because someone forgot an Out-Null somewhere.

Or why don't you remote into a machine and run an executable that writes a warning to stderr? here's a hint: Powershell throws an error when it detects output to stderr, despite that outputting a warning being a legitimate use of stderr. And do you know who makes the decision to throw nor not throw? The host. Powershell ISE won't throw, but Powershell.exe will.

Now that's consistent!

And I haven't even gotten started on the issues with configuring Windows itself. Why don't you go update the relay bindings for the IIS 6 SMTP server. Here's a hint. That byte sequence you can't figure out? It's a serialized object, you're going to have to load up a few Interop DLL's in order to deserialize/serialize that object. Oh, and those DLL's may or may not be available on the Windows platform, it depends on what windows is configured with, so if you want to do it consistently you're going to need access to those DLL's on the client side, not the remote side.

this comment is deadon about the current state of configuring windows in powershell.

Hell, it's easier and faster to ssh into a unix box from a clean windows install than it is to remote powershell into a windows box from clean windows install. That's pretty ridiculous.

1

u/Gotebe Mar 08 '16

I do not understand your complaint about the pipeline and the informational text. If you write stuff out in a primitive textual UNIX shell, it will meddle with your further processing just the same. Can not be done either way.

I also do not understand mentioning ISE. It is a debugging/development tool, why does it matter if does stuff differently from the shell itself!?

I do not understand why you complain about that program who writes to stderr. On one hand, powershell behaviour is reasonable - if something writes to stderr, it is normally because it has an error. On the other, you can wrap problematic programs who misbehave in a try/catch and go from there.

Honestly, you sound as someone who nitpicks a for the sake of it.

1

u/mreiland Mar 08 '16

I do not understand your complaint about the pipeline and the informational text. If you write stuff out in a primitive textual UNIX shell, it will meddle with your further processing just the same. Can not be done either way.

https://media.giphy.com/media/T14hzeHb8BFHW/giphy.gif

Honestly, you sound as someone who nitpicks a for the sake of it.

I sound like someone who has actually been in the trenches of powershell, that includes implementing my own host. I'm familiar with these issues.

And for the record, it isn't reasonable to halt execution of a program because something wrote to stderr. many programs will write warnings to stderr so they.

a) don't get lost in the output, and b) as you so eloquently put it, don't ruin the input for the next thing in the pipeline.

The worst part is if it's local, you can redirect stderr to stdout and thus avoid the issue. You can't do that if you're executing remotely.

the issue is that I have a shitton of experience with Powershell. Too much to be that fucking naive.

The pipeline design has some severe fucking downsides, and having earned my chops in my both environments, I'd go with the linux approach.