4 ms·
Yes, it's a rant. Why? Because probably the author is tired of explaining the same things over and over to the XML defenders Really JSON is better (and XML is
by raverbashing 15y ago
Yes, it's a rant. Why? Because probably the author is tired of explaining the same things over and over to the XML defenders
Really
JSON is better (and XML is crap) it's ridiculous, it's obvious, it's clear cut, and when people "don't get it" you start resorting to irony
Like this:
> Enclose the /element/ in matching delimiters, not the tag
Let's compare them
<blah>foo</blah>
To json
blah: foo
1 - size (json wins)
2 - matching. Here's an exercise, try splitting json with sed, and then try with XML. Sed is a good exercise, because it's limited to simple grammars, so it kind of gives an idea how much trouble it is to parse each one
3 - redundancy: what would mean if the line was <blah>foo</lala> This is a mistake, right? But I can assume the tag name is blah and the data is foo. This is a glaring redundancy in grammar, bound to cause trouble.
Not to mention working with json data (like python) is natural compared to work with XML data.
- olavk 15y agoNow try to apply this to the real world. The most popular and widely used SGML-derived format by far is (X)HTML. Show me e.g. how a paragraph with a few embedded links is improved by translating to JSON. It is not. Of course some kinds of data are indeed expressed simpler with JSON. Another real world example is RSS. More data-y that HTML but still may contain mixed content. Would it be better if it had been JSON from the beginning? The answer is not clear cut. So maybe JSON is not always the right answer. Maybe it depends on what kind of data you want to express. But then it suddely is not a debate with a "XML-defenders" which "dont get it". Then it is a discussion about which tool is approprite in a given situation rather than a war between tribes. And how do you boost you ego and sense of superiority with a boring debate about tools?
- raverbashing 15y agoPopular != Better "Show me e.g. how a paragraph with a few embedded links is improved by translating to JSON." Even though HTML and XML are related, something like a web page is so ingrained that would be difficult to change And JSON was never a markup language The criticism of XML goes much more towards using it as a 'Key/Value' serialization format. But you could imagine something like that (commas and colons would have to be replaced in a 'JSON' markup language) {p: Read it on {href:news.ycombinator.com, a:Hacker News}} Size gains, parsing speed gains. RSS is not as clear cut, really, it's not a complicated structure, so it could be YAML for example "So maybe JSON is not always the right answer. Maybe it depends on what kind of data you want to express" XML has attributes, which I'm not against (unlike the article) and it has a more natural nesting of information. But for the majority of data, yes, JSON is better This is about coder productivity (which is increased with JSON it's not even funny), either in Python/Java (even with the whole swiss army knife of XML libs they have)/C# or others. Speed is also a issue. Encoding and decoding XML is slower, even with C speedups (example: Python lxml). And this is relevant for transformation of data or even sending it to the user.
- rjknight 15y agoThis was exactly the point addressed in the OP. Quote: * SGML is a good idea when the markup overhead is less than 2%. Even attributes is a good idea when the textual element contents is the "real meat" of the document and attributes only aid processing* In your example where you want to add a small amount of markup to a large amount of text, SGML wins. JSON is a worse choice for such cases. It seems to me that we have collectively solved these problems, which is why we have both JSON and XML. Naggum was right when he said that XML was being applied incorrectly, and Douglas Crockford solved the problem by introducing JSON.
- Estragon 15y ago> Yes, it's a rant. Why? Actually, the rant's author just liked/felt compelled to communicate that way, pretty much all the time. It really hurt him socially.
- jahewson 15y agoJSON has its fair share of shortcomings too, for example: XML <p>Some <b>bold<b> text</p> JSON { "p": ["Some ", { "b": "bold" }, " text"] }
- gouranga 15y agoI wouldn't ever mark up documents like that. JSON and XML are shitty languages for such things. So is html to be honest but we're stuck with it. Markdown, rst or something are better. As long as it has a simple deterministic terse grammar that is... If you want you can stuff that inside XML or rst and attach metadata.
- jahewson 15y agoThat was the point. Markdown too has its weakness: it doesn't scale very well - how do I markup chemical symbols, or gene names, or complex tables? We soon run out of keyboard symbols to denote many concepts...
- gouranga 15y agoi agree. I think We should create and use extensible languages (both written and spoken) that are better represented and understood both machine and human. Mathematics, English and most notations are too full of nuances to represent things unambiguously.
- eta_carinae 15y ago> JSON is better (and XML is crap) it's ridiculous Except that in JSON, strings need to be surrounded by double quotes. Why impose on human readers a syntactic requirement that only compilers/interpreters need? From this respect, JSON is in the same mixed bag as XML is. If you want to go down that slope, be consistent and push YAML instead of JSON.
- raverbashing 15y ago"Except that in JSON, strings need to be surrounded by double quotes" This is a funny limitation, since JSON came from Javascript and {a:1} is perfectly legal in Javascript "Why impose on human readers a syntactic requirement that only compilers/interpreters need?" Well, for human readers this can be bad, but <> can be bothersome as well. YAML could be a better choice (or something similar to JSON but with better syntax)
- mkmcdonald 15y ago> This is a funny limitation, since JSON came from Javascript and {a:1} is perfectly legal in Javascript. That's only legal when the key is not a reserved word. I never use that form, as it's error-prone.
- antidoh 15y ago"Yes, it's a rant. Why? Because probably the author is tired of explaining the same things over and over to the XML defenders" If one is tired of talking, one's best option is to shut up.
- DavidAbrams 15y agoHe didn't say he was tired of talking. He said he was tired of REPEATING. If one is too tired to read, one should be too tired to comment on the reading material.
- mindcrime 15y ago"Yes, it's a rant. Why? Because probably the author is tired of explaining the same things over and over to the XML defenders" If one is tired of talking, one's best option is to shut up. Even better, if one's arguments are not being found persuasive, perhaps one should come up with better arguments, or reconsider their position...