Earlier quoted context omitted.
"Come back to me when you are using json to encode an entire document" How is that relevant to the article, which is about COS? In other words, what does COS lack what XML has?
* Infrastructure (schema support - DTD, Schema, RelaxNG; transformation - XSLT) * No obvious document format (What encoding are the strings? How to escape characters? * Only used to describe predefined object types (boolean, strings, arrays, dictionaries * Hard to ensure the integrity of the data without interpreting the data from the interpreter itself (no external validation)
In Defense of COS, or Why I Love JSON and Hate XML
31–40 of 46 posts
Re: In Defense of COS, or Why I Love JSON and Hate XML
#32Dings XML for crappy commenting syntax then gives JSON a pass for not supporting comments at all. I love JSON, but it does have it's issues.
Explicit is better than implicit. If you have to explain something you've probably written the JSON wrong. You can always do this: { 'people' : 10, 'desc': 'People who will attend' }
Which is why not intermingling comments with data makes sense.
>If you have to explain something you've probably written the JSON wrong.
You could say the same about code: "if you need to comment then your code isn't clear enough". In reality sometimes commenting code or data is helpful.
Re: In Defense of COS, or Why I Love JSON and Hate XML
#33XML can do the same trick with indirect objects as COS, using ID and IDREF type attributes. A number of years ago I was dealing with the archival and retrieval/display of enormous medical textbooks in XML, and I couldn't efficiently pull out arbitrary elements (chapters, sections, paragraphs, etc) because of the hierarchical nature of the XML document structure. I had to parse the whole thing to use an XPATH to get t…
For example, the COS "stream" object type is serialised as a settings dictionary, followed by the 'stream' keyword, the stream data, and the 'endstream' keyword. But what happens when the stream happens to contain the bytes 'endstream'? Well, the settings dictionary has a "Length" key that tells you how long the stream is, without you having to scan for the 'endstream' keyword. However, because most streams are compressed and compression makes it difficult to guess in advance exactly what the compressed size willl be, COS allows you to make the Length key an indirect reference to an integer defined later in the file. Like so:
>
stream
...compressed data goes here...
endstream
% And now we define object 42 revision 0
42 0 obj
12345
endobj
So, the parser needs to know the length of the compressed stream in order to parse it, but it needs to have parsed the compressed stream in order to get to the length data. The way out of this catch-22 is the object index at the end of the file, which gives you the index and location of each indirect object. A COS parser needs to start at the end of the file and load all the indirect objects, cache them, then go back to the beginning and stitch them into the deserialised object graph as they're referenced.Re: In Defense of COS, or Why I Love JSON and Hate XML
#34Earlier quoted context omitted.
YAML is better suited for configuration files.
Yaml is not good for configuration files because it is not easily human-editable. It seems "easy" but meaningful whitespace is a cluster-f ck . Edit: I have been looking for reasonable configuration file formats for a while. Json actually has pretty bad human-readability at any scale because of its quoted key-values. Yaml is easily readable but when a user tries to change anything, things go to hell. The humble ini-f…
https://github.com/triplefox/triad/blob/master/dev/com/ludam...
A "real-world" example https://github.com/triplefox/triad/blob/master/examples/Asse...
Re: In Defense of COS, or Why I Love JSON and Hate XML
#35There are also errors and approximations: XML did not introduce the bracket syntax, it inherited it from SGML. A DTD is not a schema (and if you want to criticize XML, you should point out that it should not have inherited DTDs from SGML.) He doesn't even mention the worst part about comments, which is that you can't have -- inside a comment (very annoying when commenting a large block of data...)
XML has many beautiful applications, like SVG, SMIL (which never took off but keeps getting rediscovered/reimplemented in an inconsistent manner [full disclosure: I participated in the SMIL and CDF W3C working groups]), XSLT, &c. XHTML was not perfect by a long stretch but the new HTML5 syntax is much, much worse.
Use XML, JSON, and whatever is necessary to get the job done. For the project that I am working on right now, I am using XML for serializing Web app descriptions; in this situation, XML is clearly better than JSON.
Re: In Defense of COS, or Why I Love JSON and Hate XML
#36How is COS separate from PostScript? It looks like a straight PS dictionary.
I wonder if PostScript is to COS as JavaScript is to JSON.
Re: In Defense of COS, or Why I Love JSON and Hate XML
#37Earlier quoted context omitted.
YAML is better suited for configuration files.
Yaml is not good for configuration files because it is not easily human-editable. It seems "easy" but meaningful whitespace is a cluster-f ck . Edit: I have been looking for reasonable configuration file formats for a while. Json actually has pretty bad human-readability at any scale because of its quoted key-values. Yaml is easily readable but when a user tries to change anything, things go to hell. The humble ini-f…
It seems "easy" but meaningful whitespace is a cluster-fck.
Tell that to everyone using Python. If your editor can't handle meaningful whitespace transparently, it sounds like you need a better editor.Re: In Defense of COS, or Why I Love JSON and Hate XML
#38Earlier quoted context omitted.
On the other hand, comments were explicitly excluded from JSON by Crockford (with the thinking — probably correct — that they'd be abused to embed such things as parsing directives or other out-of-band content)
I believe he was correct at the time, he removed them once people started using them for parsing directives. (JSON hasn't always been frozen)
That said, I will not pretend for a second that this is a good idea. Crockford did the right thing.
Re: In Defense of COS, or Why I Love JSON and Hate XML
#39Dings XML for crappy commenting syntax then gives JSON a pass for not supporting comments at all. I love JSON, but it does have it's issues.
Re: In Defense of COS, or Why I Love JSON and Hate XML
#40Earlier quoted context omitted.
Yaml is not good for configuration files because it is not easily human-editable. It seems "easy" but meaningful whitespace is a cluster-f ck . Edit: I have been looking for reasonable configuration file formats for a while. Json actually has pretty bad human-readability at any scale because of its quoted key-values. Yaml is easily readable but when a user tries to change anything, things go to hell. The humble ini-f…
It seems "easy" but meaningful whitespace is a cluster-fck. Tell that to everyone using Python. If your editor can't handle meaningful whitespace transparently, it sounds like you need a better editor.