|
|
|
|
|
by cben
2487 days ago
|
|
Comments are great for human-edited config files, but not a clear win for an stdout/in format. The trouble is, comments are normally defined as having no effect, not part of the data model. But iff the comments contain useful information, how do you pick it out using the next tool? Imagine having to extend `jq` with operators to select "comment on line before key Foo" etc... And if it is extractable, are they still comments? How do you even preserve comments from input to output, in tools like grep, sort, etc. XML did make comments part of its "dataset". That is, conforming parsers expose them as part of the data. Similarly for whitespace (though it's only meaningful in rare cases like pre tag but that's up to the tool interpreting data), and some other things that "should not matter" like abbreviated prefixes used for XML namespaces).
This does allow round-tripping, but complicates all tools, most importantly by disallowing assumptions that some aspect never matters, e.g. that's it's safe re-indent. I'd argue the depest reason JSON won over XML is that XML's dataset was so damn complicated. |
|