2 ms·
I'm not disagreeing but the reason XML was used as data format is that it has native support in browsers (remember XML was created as a simplified SGML subset f
by tannhaeuser 3y ago
I'm not disagreeing but the reason XML was used as data format is that it has native support in browsers (remember XML was created as a simplified SGML subset for eventually replacing HTML), the idea being that you can display service payloads via simple stylesheet applications or element replacement/decoration rather than having to rely on JavaScript or other Turing-complete environment for arbitrary scripting which was seen as having no place as a central technique in classic document-oriented browsing.
JSON became only popular because of similar opportunistic effects (ie being already part of the stack via eval()). If you look at how typical non-JS backends such as Java or .net deal with service request/response data, there's absolutely no advantage for either JSON or XML - both are represented as class/structure and (de-)serialized via binding frameworks and annotations.
- strken 3y agoThere's no particular machine advantage to any human-readable format over an equivalent binary format, sure. However, if you look at human-"readable" formats that predate XML (like HL7[0]) you can appreciate the advantages of a tree-like structure with labelled fields when it comes to human comprehension. I think XML is often difficult for humans to read, and certainly to write, and since this is the only reason to use either language it's an important factor. I guess you could argue we should all use Protocol Buffers, pickle, Thrift, etc.[1] and only switch to JSON for debugging. I wouldn't disagree. Protobuf is apparently faster than JSON in the browser. [0] See https://www.interfaceware.com/hl7-message-structure https://www.interfaceware.com/hl7-message-structure for an example message [1] I missed Corba and spent the early years of my professional life trying not to touch the SOAP, just in case I dropped it
- nrclark 3y agoJSON does have one advantage over XML: it maps cleanly onto primitive types in Python and many other languages. XML attributes don’t really have an unambiguous way to be represented using list and map primitives (other than maybe an “everything is a map” model, which sucks from a usability perspective).
- aforwardslash 3y agoI beg to differ. JSON only provides a subset of commonly available data types (quick example: show me a proper 64 bit int, a proper date type or a proper money type). And "everything is a map" is pretty much how python works, but they prefer to call it dicts. I could go on and explain how JSON is evolving to have exactly all the problems of xml without any of the advantages, and how people keep reinventing the wheel (pun intended for python fans) ignoring why xml is the way it is (and it is quite more robust than anything json). Xml biggest defect was verbosity, specially in a http 1.0 context. With http 1.1 (so nowadays, legacy tech) , most of these problems disappear. I know, parsing of json is quite simple - the reason is the format is lacking.