News for hackers. Stuff that matters.
[dead]
Re:PowerShell is open sourced and is available on Linux by blakeyrat on Thursday August 18, 2016 @05:56PM (#12316614)
The dollar sign is charming.

There's a few points here:

1) Not all data is text. In fact, very little of the data people see/work with day-to-day is raw text. It's silly to transform a PNG image into text to be able to pipe it around. (Or to pipe around its filename instead and have a dozen tools all having to open and re-parse it each time.)

2) There's nothing on PowerShell preventing you from serializing a piece of data to text if you want to. The key is: you don't have to.

3) Systems that depend on 50,000 CLI tools all having their own ad-hoc text parsers are cemented, mummified, cannot change. You can't change the output format of ps (to use an example in this thread) without breaking an unknown number of CLI tools. Even if you come up with a great way to improve the output, doesn't matter, you've still broken everything. This is less (but not none!) of an issue with PowerShell. I like computers to evolve to become better over time, and text-based CLIs are a huge anchor preventing that.

Re:PowerShell is open sourced and is available on Linux by dragonwriter on Thursday August 18, 2016 @06:09PM (#12316681)
Unfortunately PowerShell relies on everything running on .NET (well, I think COM works, too); the idea of a shell that can expose live objects is useful, but PowerShell's platform limitations in reality doing that make it a far from ideal implementation of that concept. Something built on a protocol that is platform agnostic would be better.
Re:PowerShell is open sourced and is available on Linux by Const-me on Thursday August 18, 2016 @10:07PM (#12317545)
Live objects don’t usually expose any protocols at all. They only expose an ABI. Do you know any platform-agnostic OO ABI, besides what’s in .NET?

If you’ll wrap your objects into some platform-agnostic protocol like JSON, you gonna waste enormous amount of CPU time parsing/formatting those streams at the object’s boundaries.

Re:PowerShell is open sourced and is available on Linux by tracker1 on Friday August 19, 2016 @05:27AM (#12318853)
You can run streams of many millions of JSON objects pretty much as fast as the IO can feed it... most of the time, in situations like this, you're constrained by IO speed, not CPU... assuming you are working with a stream that has flow control.

I tend to dump out data structures to line terminated JSON, and it works out really well for streams, can even gz almost transparently. Parse/stringify has never been the bottleneck... it's usually memory (to hold all the objects being processed, unless you block/pushback on the stream), or IO (the feed/source of said stream can't keep up).

Re:PowerShell is open sourced and is available on Linux by Const-me on Friday August 19, 2016 @02:21PM (#12322165)
Even if printing and parsing is computationally cheap, memory allocation is less so.

If you expose JSON, each serialize/deserialize will produce another instances of objects, with the same data.

The architecture of PowerShell implies commands in the pipeline can process the same instances, without duplicating them.

Another good thing about passing raw objects instead of JSON — live objects can contain stuff expensive or impossible to serialize. Like an OS handle to an open file. Sure, with JSON you can pass file names instead, but this means commands in your pipeline need to open/close those files. Not only this is slower (opening a file requires kernel call, which in turn does various security checks for user’s group membership and file system’s inherited permissions), but can even cause sharing violations errors when two commands in the pipeline try accessing the same file.

Re:PowerShell is open sourced and is available on Linux by to3m on Friday August 19, 2016 @07:02AM (#12319188)
And just think how much faster it would be if there were no serialization and I/O involved at all...
Re:PowerShell is open sourced and is available on Linux by tracker1 on Monday August 22, 2016 @11:03AM (#12336792)
And my method can work over distributed systems with network streams... There are advantages to streams of text.
Re:PowerShell is open sourced and is available on Linux by Const-me on Monday August 22, 2016 @10:54PM (#12341052)
What advantages?

PowerShell works over networks just fine, because standardized ISO/IEC 17963:2013 protocol a.k.a. WS-Management.

Re:PowerShell is open sourced and is available on Linux by crpatino on Thursday August 18, 2016 @06:27PM (#12316763)
> Even if you come up with a great way to improve the output, doesn't matter, you've still broken everything.

You phrase this as if changing things for the sake of changing was a good thing. It is not.

Well, perhaps it is good for the software vendor, but from the customer's point of view, having to re-learn how to do the same stuff over and over every other year is a PITA.

Re:PowerShell is open sourced and is available on Linux by blakeyrat on Friday August 19, 2016 @10:05PM (#12324741)
This is why I have trouble getting along with Linux users.

Without change, there's no improvement.

Re:PowerShell is open sourced and is available on Linux by Retra on Friday August 19, 2016 @01:18AM (#12318107)
It's often the customers who are complaining that your current output is not suitable.
Re:PowerShell is open sourced and is available on Linux by qwertyuiop924 on Friday August 19, 2016 @12:03PM (#12320993)
First off, you can pipe binary data around. Most tools just expect text.

Secondly, if you used DSV to parse PS, like you should, adding a new column to the end won't break anything. A fancier parser won't even break if you add to the middle, but that's usually not worth the effort to write.

Re:PowerShell is open sourced and is available on Linux by MaulingMonkey on Thursday August 18, 2016 @06:50PM (#12316853)
> What the M$ community fails to see is that text streams can be consumed by __everyone__.

Text can be poorly parsed by everyone, yes. I especially love it when the default tools settings mean two different computers will give different text results, because the installation defaults changed at some point. What's not to love about trying to properly escape and unescape strings via the command line, while simultaneously keeping in mind your own shell's escaping, and having scripts which are neither backwards nor forwards compatible? And this is to say nothing of different distros.

It's as if the text was built for humans instead of my tools half the time, or something. I usually try to centralize my parsing of text in one place so when it invariably breaks, I don't have to rewrite my entire shell script.

Some basic structuring - I hesitate to call it a brittle object model, when most of the time I'm dealing with something more akin to C structs than invariant and abstraction laden Smalltalk or somesuch, or Java's sprawl of factories and inheritance - makes things a bit easier. New fields can be added without breaking my regular expressions. I don't need to worry about escapes to handle special characters. I can trivially dump to text for display (by simply running the command as this is the default behavior of the shell), or to feed into text consuming tools.

Re:PowerShell is open sourced and is available on Linux by temac on Thursday August 18, 2016 @05:18PM (#12316397)
It's even more than that: text formatting allows the use of generic filtering and text processing tools. Whereas if you are using objects, you will tend to use less on-the-fly command line composition, and write or reuse more tools dedicated to one particular object or the other. In the end I'm not sure keeping the structuring as the default use case yields an usage so much improved in the real world, because if you work on a broad number of types you will tend to need to know more specialised tools, instead of generic ones, and have less higher-order composition tools at your disposal.

Now of course you can always format to text from your structured object, but this does not matter. What matters is what is convenient in the proposed UI, and what is mainly practiced in the real world because of such convenience and the amplification loop it creates between tools authors and users.

Also some objects are originally handled in text form, and their structured decomposition is extremely complex compared to an informal description and the naturally refinable heuristic which comes with it. For example you can grep into a source code in any language (with more or less efficiency depending on the language, but at least if there is a unique symbol you will find it), whereas trying to get and handle it in a structured way basically means you would need half of a (modular) compiler, and a huge manual to describe the structure, and possibly a non trivial amount of code to actually do the lookup.

The PowerShell approach is not all-bad, though, and obviously there are some usages where it superior to text based shells. But for a day to day usage as a general purpose shell, and a programmer shell, I'll stick to the Unix approach.

Re:PowerShell is open sourced and is available on Linux by Firadeoclus on Friday August 19, 2016 @07:39AM (#12319337)
Structured data allows the use of generic filtering and structured data processing tools. The basic requirement is reflection, objects being able to tell you about their structural composition.

If code was stored in a structured representation you could still search for a string object containing a symbol name in the structured representation. You can match a structure pattern just like you match a regex to text.

Typical shells can be thought of as REPL for a programming language that makes the file system easily accessible and uses said file system or pipes to pass around data between functions/commands, sometimes as human-readable text. Most programming languages don't encourage passing data around as strings.

Re:PowerShell is open sourced and is available on Linux by ygra on Thursday August 18, 2016 @03:55PM (#12315839)
Nothing prevents me from changing those objects into a text stream. In fact, it's infinitely easier than turning a text stream into objects.
Re:PowerShell is open sourced and is available on Linux by mbrumlow on Thursday August 18, 2016 @04:28PM (#12316095)
I feel you missed my point. It's not just a stream of raw data. It's a stream of formatted text... There is no magic or hand waving involved.
Re:PowerShell is open sourced and is available on Linux by NetStrikeForce on Friday August 19, 2016 @06:32AM (#12319088)
I guess that's why HTTP2 is now binary, because text is awesome.

https://http2.github.io/faq/#why-is-http2-binary