News for hackers. Stuff that matters.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @07:47AM (#13166379)
Structured text is good. Very good, in fact. It might even be idea. structured binary data, less so, at least as a storage format.

I want to be able to look at your file format using tools that haven't been specialized to the task. Is that so wrong?

Re:The Rule of Silence (2006) by TeMPOraL on Tuesday December 13, 2016 @08:07AM (#13166473)
Well, I'm advocating for structured text, not binary. Mostly because I haven't seen a future-proof binary format yet, and editing binary formats indeed would require special tooling. I think - for a data exchange protocol meant to be used between many applications - going structured text instead of binary is a worthwhile tradeoff of little lower efficiency vs. much better accessibility.

EDIT: Some comments here are slowly making me like the idea of a standard structured binary more and more.

Re:The Rule of Silence (2006) by ryandrake on Tuesday December 13, 2016 @10:08AM (#13167291)
Let's say I want to know how many days since an asset on my web server has been modified. With bash + some standard unix tools, from the top of my head I have to do something like this:

    curl -svo /dev/null http://example.com/file 2>&1 | grep Last-Modified | cut -d ' ' -f 3-
And that's just to get the last modified date in text form. Now I'm writing a script that parses that date and gets today's date, convert them to days, and subtract. YUCK!

Wouldn't it be nice if your shell could do this?

    curl(http://example.com/file).response_headers.Last-Modified.subtract(date().now).days
I think it would be nice.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @01:20PM (#13169097)
Yes, but as it stands, most of those would have to be builtins for that to work. I would rather have:

   curl -j example.com|select headers.Last-Modified|time before now|time to days
Where the commands send and receive JSON.
Re:The Rule of Silence (2006) by bandrami on Tuesday December 13, 2016 @09:46AM (#13167099)
Can you name me a single UNIX configuration file whose format is not "structured"?
Re:The Rule of Silence (2006) by TeMPOraL on Tuesday December 13, 2016 @10:27AM (#13167445)
Config files are less of a problem. The issue is with programs, which you want to use with pipes. Each has its own undocumented, arbitrary pseudo-structure with often inconsistent semantics, optimized for viewing by user.
Re:The Rule of Silence (2006) by bandrami on Tuesday December 13, 2016 @10:40AM (#13167558)
What programs are you thinking of? Maybe this is my sysadmin bias but about 90% of my UNIX tools usage is on config files...
Re:The Rule of Silence (2006) by JdeBP on Tuesday December 13, 2016 @11:08AM (#13167805)
Let me suggest an incendiary example: systemd

systemctl status wibble.service : Displays human-readable information, with colours, line drawings, and variable-length free-form text; that is exceedingly hard for a program to parse reliably.

Contrast with

systemctl show wibble.service : Outputs machine-readable information, in systemd's favourite form of a Windows INI file.

Re:The Rule of Silence (2006) by bandrami on Tuesday December 13, 2016 @11:11AM (#13167823)
Yikes. Makes me glad I run Slackware. Though I seem to recall from The Init Wars that it was precisely this quality of SystemD that made people lob the charge that it violated the "Unix philosophy"
Re:The Rule of Silence (2006) by TeMPOraL on Tuesday December 13, 2016 @02:30PM (#13169968)
ls, ps, du, df, ... pretty much all CLI tools. The kind you use in scripts.
Re:The Rule of Silence (2006) by bandrami on Tuesday December 13, 2016 @03:44PM (#13170801)
All four of which users are enjoined, over and over again, not to try to parse the output of (particularly ls). That is, those are the tools specifically not meant to be connected by pipelines, but merely used for operator convenience.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @05:17PM (#13171666)
...But how do you extract that data otherwise?
Re:The Rule of Silence (2006) by bandrami on Wednesday December 14, 2016 @08:25AM (#13175743)
Instead of ls, find. Instead of ps, you parse the nodes in the /proc filesystem that ps itself parses. Ditto the /sys filesystem and du/df.
Re:The Rule of Silence (2006) by qwertyuiop924 on Wednesday December 14, 2016 @01:30PM (#13178365)
When those tools were written, /sys and /proc didn't exist.
Re:The Rule of Silence (2006) by borplk on Tuesday December 13, 2016 @08:16AM (#13166512)
It's only "specialized" because we haven't been doing it so it's considered special.

At some point you have to admit that what's meant for the computer is not always byte by byte the same as what's meant for the human.

We try to shove these two together and we screw up both of them.

Empower the computer to be the best that it can be by taking the human out.

Empower and respect the human by giving him/her their own representation.

The "I just want to read the bytes that are on disk" philosophy is inherently limiting and broken when the audience are two very different things (humans vs computers).

My argument is that instead of fighting that we must embrace it.

Re:The Rule of Silence (2006) by xg15 on Tuesday December 13, 2016 @08:07AM (#13166474)
Yes, because it's: a) inefficient b) invites a lot of wrong assumptions about the storage format, e.g. about the underlying grammar, the maximum length of tokens or the possible characters than could occur in the file. c) requires you to solve the same problems over and over again (how to represent nested lists, graphs, binary blobs, escaped special characters, etc) d) encourages authors to roll their own format and not research if there maybe is an existing format that would solve their case.

I agree with you, the other extreme - treat binary files as sort of opaque black boxes that you can only access with specialized tools beloniging to your application - is even worse. But I don't see why we can't reach some middle ground: have a well-documented, open, binary format that encodes a very generic data structure (maybe a graph or a SQLite-style database) and a simple schema language that lets you annotate that data structure. Then you can develop generic tools to view/edit the binary format even though every application can use it in their own way.

Re:The Rule of Silence (2006) by dagw on Tuesday December 13, 2016 @07:52AM (#13166402)
Parsing structured text is slow and inefficient. Also reading out just one part of a data structure stored as text often requires either walking through the file character by character or first slurping the whole thing into memory.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @07:58AM (#13166432)
...But when your system crashes, having all that data in an easily accessible manner (regardless of what tools you have on hand) is a major win.
Re:The Rule of Silence (2006) by michrassena on Tuesday December 13, 2016 @10:04AM (#13167260)
Let's not forget that when your system crashes, all of these easy-to-read text files are actually stored in a binary format, sometimes scattered in pieces, and require special tools to extract.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @01:21PM (#13169104)
True, but they're less fragile: even if the text is garbled, you might be able to get some information out of it.
Re:The Rule of Silence (2006) by imtringued on Tuesday December 13, 2016 @08:41AM (#13166667)
A text editor is specialised to the task of viewing and modifying text in a certain format.
Re:The Rule of Silence (2006) by qwertyuiop924 on Tuesday December 13, 2016 @01:22PM (#13169116)
Wrong. It's specialized to viewing and modifiying any text, regardless of format. That's a huge difference.