News for hackers. Stuff that matters.
Re:Bringing the Unix philosophy to the 21st century (2019) by natt941 on Sunday August 22, 2021 @12:20PM (#28266759)
I can understand why the idea of more structured, object-like input and output is appealing, but after using PowerShell for a while, my take is that it's much harder to manipulate objects into a consistent format than it is to manipulate text. For instance, if you want to compare Azure DNS records with DNS records from a Windows server, it's a huge pain because Get-AzDnsRecordSet and Get-DnsServerResourceRecord return objects with different structures. Same problem if you want to pipe output of one util to another which expects slightly different format of input. More generally, text is great for loose coupling; structured objects, less so.
Re:Bringing the Unix philosophy to the 21st century (2019) by zozbot234 on Sunday August 22, 2021 @12:44PM (#28266991)
> More generally, text is great for loose coupling; structured objects, less so.

I disagree. Parsing "loose coupled" text and converting it to the format that a different tool expects is a rather non-trivial problem, and one that's often poorly specified to begin with; converting structured outputs is generally straightforward in comparison.

Re:Bringing the Unix philosophy to the 21st century (2019) by guenthert on Sunday August 22, 2021 @09:00PM (#28271261)
Sure, converting (or interpreting) structured data is easier then unstructured. I doubt anyone is arguing that. I interpret op's statement however in that unstructured data is easier to couple unrelated tools. Tools perhaps which haven't written yet, by teams not knowing of each other and hence are unable to agree on a structure.
Re:Bringing the Unix philosophy to the 21st century (2019) by kbrazil on Sunday August 22, 2021 @09:40PM (#28271536)
I feel like if that were true then you’d have the majority of REST APIs delivering unstructured output instead of structured JSON, XML, CSV, etc. The market has spoken - there is true utility in structured text output.
Re:Bringing the Unix philosophy to the 21st century (2019) by zamadatix on Sunday August 22, 2021 @12:53PM (#28267094)
I think that's why the article proposes adding command line options and alternative APIs to output JSON objects not forcing all things the use objects all the time.

For any serious data retrieving or scripting the light object wrapping will be superior. For quick one off use maybe the plain text option will be quicker to reason about.

Re:Bringing the Unix philosophy to the 21st century (2019) by crdrost on Sunday August 22, 2021 @01:35PM (#28267594)
It's that the languages suck.

I've tried writing a language around this but it's... rusty. You kind of want to pipe Get-AzDnsRecordSet and Get-DnsServerRrsourceRecord to the same interface structure and then build another transform to some other structure from the interface... The program wires together the transforms. So the programming paradigm becomes rather unconventional, you only write transformations of “events”, you address other shell commands by listening to outputs of their “eventspace,” etc. ... You get a sort of strange logic programming language where the pipe operator has to be slightly specialized every time because it always needs to transform a little as it pipes

Re:Bringing the Unix philosophy to the 21st century (2019) by jayd16 on Sunday August 22, 2021 @01:25PM (#28267501)
You can always just thunk down to the text representation and do things that way. Having the structure is a strict plus, no?
Re:Bringing the Unix philosophy to the 21st century (2019) by ori_b on Sunday August 22, 2021 @03:10PM (#28268512)
This is a much more complex text representation.

Mandating tab separated columns with a consistent quoting for embedded spaces would be a net benefit. And it would match today's tools well.

Re:Bringing the Unix philosophy to the 21st century (2019) by laumars on Sunday August 22, 2021 @04:36PM (#28269358)
There are better shells out there for handling structural data, like Murex and Elvish
Re:Bringing the Unix philosophy to the 21st century (2019) by laumars on Sunday August 22, 2021 @07:23PM (#28270697)
No seriously, there really are. I appreciate it requires learning a new tool but rather than downvoting me how about those unconvinced ask me questions instead? I’m happy to answer.

While there will always be a need to keep Bash around for comparability, there are a plethora of other tools out there that solve many of the shortcomings of POSIX.

Re:Bringing the Unix philosophy to the 21st century (2019) by lambdaba on Sunday August 22, 2021 @10:51PM (#28271866)
Are you using one of these exclusively? Which one have you chosen and why?
Re:Bringing the Unix philosophy to the 21st century (2019) by laumars on Monday August 23, 2021 @05:29AM (#28273777)
I use murex exclusively. It’s still beta quality so not totally bug free but the bugs are rarely showstoppers and it’s still in active development so fixes are usually just one GitHub issue away.

I don’t use it on servers, I stick with Bash for that. But I do use it as my primary local shell.

As for why murex, that’s a combination of personal preference and simply not being aware of other shells until after I’d already started using murex.

What I like about it is it’s typed and does a lot of the boring stuff automatically in the pipeline based off what type is (JSON, YAML, CSVs etc are all “types”). So working with a JSON file is as natural as working with a flat text file. But also it’s trivial to bypass the clever stuff and use it like a dumb bash shell too. Which is where Powershell and its ilk fall down.

Re:Bringing the Unix philosophy to the 21st century (2019) by lambdaba on Tuesday August 24, 2021 @04:15PM (#28294374)
Thank you, I'll check out Murex.