Earlier quoted context omitted.
Separate tools have the advantage (over regex) of handling nesting properly, which could certainly be significant. On the other hand, handling deep-enough nesting with regexp is usually not hard, and when you're stringing together a bunch of unix commands quickly you're usually looking for "good enough". I don't want to have to write a new everything to handle a new format. Maybe there's something in between?
I guess I didn't explain well enough, since you completely misunderstood my suggestion. Separate tools have the advantage (over regex) of handling nesting properly, which could certainly be significant. Okay, thanks, but I've known about basic automata theory since I was an undergrad, two decades ago. I had something like this in mind: ls -af | jsonify 'ls -af' | this_reads_a_json_stream The jsonify command would ret…
Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
61–70 of 112 posts
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#62Earlier quoted context omitted.
The real problem is that Unix commands produce flat text output without any information about how to parse that text back into structured data. Any user who wants the structured version of the data has to parse it themselves, but these parsers are ad hoc and incomplete by their very nature. There are a variety of serialization schemes that are quite easy to parse and would be suitable for the output of most Unix comm…
> JSON would do nicely as well. Yep, some friends of mine did this with JSON, but didn't make the schema explicit like I mean to: https://github.com/benbernard/RecordStream > Better yet, unify the shell with a virtual machine that is used to implement the OS, and have everything available as 1st class Objects. Please no. This is the Microsoft PowerShell approach, where everything is a .NET object. Once you start dict…
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#63Earlier quoted context omitted.
First thing I looked for when I checked the comments, was there a mention of Powershell. Powershell has the concept of passing objects (via .net clr) instead of passing strings. It sucks when trying to deal with streams of data, but fantastic for acting as script glue between various systems. One of the things I feel Microsoft really got right.
First thing I checked for too. Second thing I looked for was someone pointing out that this is asking for object oriented systems (such as Smalltalk or Self). But the third thing, no one mentioned: SNOBOL. Reportedly (because I haven't used it myself) it is better than AWK for complex matching.
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#64Earlier quoted context omitted.
I could not agree more with your comment. There's not a problem with text. Why do people pretend there is? They often only achieve making other people's jobs more difficult. Text is what people can read. People do not read binary. When something goes wrong, debugging binary formats becomes insanely cumbersome. The concept of lines is a human one. It is how humans parse. If humans could parse without needing the conce…
> I could not agree more with your comment. There's not a problem with text. Why do people pretend there is? My problem is not with text per se, but with unstructured text. I'm fine with JSON in cases where efficiency is not a top concern. Let me ask you this; how would you do the equivalent of this hypothetical command? $ ls | structured-grep 'file.size > 1M' The answer is that you can't in today's world without wri…
ls | find -size +1M
On the other hand, if you want to make list of files and their sizes, that can be stored, sent over the network, etc -- and then filer that list, you can do: ls --size | awk 'file_blocks=$1 $file_blocks > 1024 { print $2 }'
For most tasks, I think the fact that any human can look at the output from eg: "ls --size" and then produce a valid test dataset in the same format is more valuable than having to explicitly "cast" the metadata while processing.Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#65Earlier quoted context omitted.
I could not agree more with your comment. There's not a problem with text. Why do people pretend there is? They often only achieve making other people's jobs more difficult. Text is what people can read. People do not read binary. When something goes wrong, debugging binary formats becomes insanely cumbersome. The concept of lines is a human one. It is how humans parse. If humans could parse without needing the conce…
> I could not agree more with your comment. There's not a problem with text. Why do people pretend there is? My problem is not with text per se, but with unstructured text. I'm fine with JSON in cases where efficiency is not a top concern. Let me ask you this; how would you do the equivalent of this hypothetical command? $ ls | structured-grep 'file.size > 1M' The answer is that you can't in today's world without wri…
# find . -maxdepth 1 -size +1M
really, flat text is fine. Maybe it's not perfect, but it's good enough that most want to not add any complexity to it that would make it incompatible.
And if you really need that complexity, it's usually worth whipping up a parser for.
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#66Earlier quoted context omitted.
> JSON would do nicely as well. Yep, some friends of mine did this with JSON, but didn't make the schema explicit like I mean to: https://github.com/benbernard/RecordStream > Better yet, unify the shell with a virtual machine that is used to implement the OS, and have everything available as 1st class Objects. Please no. This is the Microsoft PowerShell approach, where everything is a .NET object. Once you start dict…
How can your tools all accept the same kind of structured data without dictating its representation? I don't get it.
ORS=: OFS=, ls -l # rw-r--r--:1:uname:gname:1025:Jun 1:somefile.txt,...,...
Add a specifier for dates, usernames, groupnames, etc. DSF="%Y-%m-%d" ls -l
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#67Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#68Earlier quoted context omitted.
> I could not agree more with your comment. There's not a problem with text. Why do people pretend there is? My problem is not with text per se, but with unstructured text. I'm fine with JSON in cases where efficiency is not a top concern. Let me ask you this; how would you do the equivalent of this hypothetical command? $ ls | structured-grep 'file.size > 1M' The answer is that you can't in today's world without wri…
>>Let me ask you this; how would you do the equivalent of this hypothetical command? >> $ ls | structured-grep 'file.size > 1M' # find . -maxdepth 1 -size +1M really, flat text is fine. Maybe it's not perfect, but it's good enough that most want to not add any complexity to it that would make it incompatible. And if you really need that complexity, it's usually worth whipping up a parser for.
> And if you really need that complexity, it's usually worth whipping up a parser for.
No work is worth doing if it could just as easily have been avoided.
The vision in my head has less complexity than the status quo, not more. How many flags does "find" have? One for every field name you can filter/sort by. Done right, a "structured-grep" that can grep on any field sent to it is much, much simpler.
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#69Earlier quoted context omitted.
> JSON would do nicely as well. Yep, some friends of mine did this with JSON, but didn't make the schema explicit like I mean to: https://github.com/benbernard/RecordStream > Better yet, unify the shell with a virtual machine that is used to implement the OS, and have everything available as 1st class Objects. Please no. This is the Microsoft PowerShell approach, where everything is a .NET object. Once you start dict…
How can your tools all accept the same kind of structured data without dictating its representation? I don't get it.
Yes, you have to agree on a serialization format (JSON, Protocol Buffers, etc), but that's not the same thing. From a serialization format you can represent the data however you see fit in your process. For example, a C++ user might represent a string as a std::string object whereas a Python user would represent it as a native Python string.
The VM-based approach (like PowerShell) defines an in-memory tree representation, namely .NET objects. This means that you can't really interoperate with this stack unless you use .NET too, since you don't have an easy way of converting .NET objects to your own objects.
Re: Rob Pike: "Current Unix tools are weakened by the built-in concept of a line"
#70The real problem is that Unix commands produce flat text output without any information about how to parse that text back into structured data. Any user who wants the structured version of the data has to parse it themselves, but these parsers are ad hoc and incomplete by their very nature. People praise perl, sed, awk, cut, etc. for being good at text processing. But the only reason they need these text-processing t…