8 ms·
I’m going to just argue the exact opposite of the article: xml and json are both structured data formats useful for tree like data graphs, such as objects. Whe
by alkonaut 7y ago
I’m going to just argue the exact opposite of the article: xml and json are both structured data formats useful for tree like data graphs, such as objects.
Whether that was the intended purpose when xml was designed is irrelevant. It’s what xml is used for in almost every case.
The author also doesn’t suggest what should be used instead to encode structured data, or perhaps more importantly what should have been used to encode graph like things such as map/lists/objects in the 2000’s. Json really hasn’t been an alternative until quite recently (10 years ago?).
In fact reading the article carefully I fail to see the author argue why xml shouldn’t be used as a data format either.
- miggol 7y agoI'd argue that for data storage purposes, you'd like to have a low metadata to information ratio. In the examples the author gives this seems to be the main problem, with way more characters being used for markup than for content. Compare that to JSON or TOML, which are more human-friendly and waste fewer bytes on structure to convey the same information. When used for data storage, two XML files of the same schema describing two completely different objects are likely to share a large amount of content, which is wasteful and gets in the way.
- RantyDave 7y agoI beg to differ. For a start, XML compresses well and besides, storage is monster cheap these days. XML is a better storage format because it documents what the data is (a title, a reference etc) as well as the data itself. There are many better reasons to hate XML.
- hnick 7y agoXML does compress well as text or over the wire but the parsing trees can be quite large in memory and processing consumption. At least in Perl I've had enough scripts crash out due to this overhead when implementing the common/naive solution using off the shelf modules. You can get around this by choosing between DOM or SAX but I consider that a symptom of the problem, you choose XML to solve a problem and now you have another problem to solve.
- Mikhail_Edoshin 7y agoI had the same problem with npm, I think, and JSON, because npm could not simply load the huge JSON file into memory. A huge anything can crash a naively written tool used to handle smaller instances.
- hnick 7y agoThat's true but I think XML has the edge there. It has so many features like defining new types which you wouldn't normally see in JSON. One parser we used had a ten to one ratio - 50MB of XML meant 500MB of RAM usage when using a DOM parser. And that's taking into account the textual representation of XML is already >50% bloat with the closing tags etc.
- dfox 7y agoFor storage of structured data (and probably even for loosely coupled RPC) you want format that is efficient and schema-oblivious. The bad choice 15 years ago was XML, bad choice today is JSON (the parsing overhead is not negligible) or ProtoBufs (not schema-oblivious). Various binary formats with JSON-like object model seems like the way to go (my choice is CBOR). And then there is the EU-wide absurdity of WhateverAdES, which invariably leads to onion-like layers of XML in ASN.1 encoded as base64 in XML wrapped in CMS DER encoded message...
- Koshkin 7y agoWell, XML is a markup language (and is really good at being that) while JSON is not. Sure, XML can be used as a poor man's data storage, as a base for a DSL, etc., but almost always there are better choices.
- jeremyjh 7y agoYou aren't responding to the comment here, you are just reasserting the article's position. I'd argue there is not another format that is obviously better for every data storage or exchange use case, or that surpasses all of XML's benefits while minimizing all of its downsides. I don't want to look at XML, but I do understand why it is being used.
- deleted 7y ago[deleted]
- gambler 7y agoAbuse of XML killed it a format. JSON is absolutely shit for semantic markup, and yet developers today routinely use it for documents because "XML is bad". They contrive ridiculous schemes for adding metadata and type information. They use it to generate HTML even when HTML takes less space. Finally, we regressed from XTML to HTML5. Buy-buy namespaces and parsing consistency.
- sedachv 7y agoSGML being replaced by XML being replaced by JSON is great proof that the idea of progress in tech is at best a myth and at worst a lie.
- barberousse 7y agoI mean, the idea of progress in general is barely agreeable outside of recent strides in the physical sciences
- myrryr 7y ago
- taberiand 7y ago> what should be used instead to encode structured data, or perhaps more importantly what should have been used to encode graph like things such as map/lists/objects in the 2000’s Lisp?
- josteink 7y agoThat this answer is voted down, on HN of all places, is kinda sad. It may not be the popular answer, but it’s definitely a valid answer.
- taberiand 7y agoIt was because I said Lisp instead of s-expressions - I find imprecise language is always a good way to garner down-votes on HN
- soapdog 7y agoI think you mean s-expressions instead of lisp and if you do, I'm with you. They are really neat and underused. Now, if you want to carry a whole language runtime for the structured data format you'll probably end up with the "which lisp" kind of problem in which each app end up using something different and then the structured data files are no longer exactly portable (until you devise a portable standard yadayadayada)
- taberiand 7y agoYes! I meant s-expressions, the name escaped me - thanks.
- AnimalMuppet 7y agoI have to admit, once you've seen S-expressions, XML looks insanely bloated and verbose. The advantage XML would have in that situation is that, because it's so verbose, if you get a malformed XML, you can eyeball-parse it and often figure out how to hand-edit it to make it valid. If it is valid, you can also see exactly how the schema you were sent differs from the schema you expected. An S-expression, having less redundancy, also is potentially more brittle.
- wpietri 7y agoThe intended purpose is relevant because it tells us the conditions under which something is likely to work well. XML was vastly overused for a long time. That doesn't make those usages correct, as there were alternatives even then. (It also doesn't make people who overused somehow bad; I think it was a reasonable and necessary mistake.) It certainly doesn't make new ones correct now given that JSON's been around 16+ years. [1] I think the author here is slightly strong in his criticism; I think XML is great for things that are meant to be long-lived and self-documenting. That is, things that are used like documents. But if I'm passing short-lived globs of structured data back and forth, as with an API, I think JSON's a much better fit, as is Protobufs for more tightly joined code. [1] https://web.archive.org/web/20030228034147/http://www.crockford.com/JSON/index.html https://web.archive.org/web/20030228034147/http://www.crockf...
- democracy 7y ago10 years ago the idea of having json anywhere but in the browser was crazy in the enterprise sphere
- wpietri 7y agoSure, but the enterprise sphere is mostly what Moore called late majority and laggards. The biggest driver of use is not effectiveness, but perceived safety. A good proof of that is your choice of word here: crazy. It's not that JSON would have been somehow technically wrong; it was just socially wrong.
- dragonwriter 7y ago> The intended purpose is relevant because it tells us the conditions under which something is likely to work well. Not really. Plenty of things suck at their original intended purpose and remain in use because they are very good for some other purpose. (Viagra is an example well-known to popular culture, but hardly unique.) > XML was vastly overused for a long time. That doesn't make those usages correct, as there were alternatives even then. XML is perhaps not abstractly ideal for many of the purpose it has been used for, but in many cases it was superior to other alternatives for practical reasons, particularly the tooling ecosystem. (JSON is the new XML, and virtually the same thing can be said for JSON in many of its current uses, though it does clean up XMLs two biggest warts, element/attribute distinction and verbosity—though even for human readable formats YAML does the latter even more than JSON while being easier to read, not to mention all the binary options when readability isn't a concern.)
- deleted 7y ago[deleted]
- rauhl 7y ago> The author also doesn’t suggest what should be used instead to encode structured data, or perhaps more importantly what should have been used to encode graph like things such as map/lists/objects in the 2000’s. That’s easy: S-expressions. Steve Yegge wrote about this in 2005: https://sites.google.com/site/steveyegge2/the-emacs-problem https://sites.google.com/site/steveyegge2/the-emacs-problem Would you rather have: <?xml version="1.0" encoding="utf-8" standalone="no"?> <!DOCTYPE log SYSTEM "logger.dtd"> <log> <record> <date>2005-02-21T18:57:39</date> <millis>1109041059800</millis> <sequence>1</sequence> <logger></logger> <level>SEVERE</level> <class>java.util.logging.LogManager$RootLogger</class> <method>log</method> <thread>10</thread> <message>A very very bad thing has happened!</message> <exception> <message>java.lang.Exception</message> <frame> <class>logtest</class> <method>main</method> <line>30</line> </frame> </exception> </record> </log> or: (log '(record (date "2005-02-21T18:57:39") (millis 1109041059800) (sequence 1) (logger nil) (level 'SEVERE) (class "java.util.logging.LogManager$RootLogger") (method 'log) (thread 10) (message "A very very bad thing has happened!") (exception (message "java.lang.Exception") (frame (class "logtest") (method 'main) (line 30)))))
- lstamour 7y agoFrankly, I’d rather some form of compressed binary logs, but sure, either works if it includes a stack trace and I need it at the time! Text logs compress well anyway, they just grow larger if/when you process them later... I’m just happy to see objects as log entries instead of plaintext strings. ;)
- EdwardDiego 7y agoI have no strong preference for either, so long as both of them convey the structured information I need. Although tbh I'm preferring the XML in your example due to the lack of random quotes - why does (record need a quote, but (log doesn't? The XML seems a lot more consistent.
- 7y ago