4 ms·
Could someone who knows a lot about these things tell me why JSON took such a long time to arrive? JSON, at its core, is essentially a hierarchy of maps and li
by Xcelerate 14y ago
Could someone who knows a lot about these things tell me why JSON took such a long time to arrive?
JSON, at its core, is essentially a hierarchy of maps and lists -- which seems a very intuitive and useful way to store data.
XML on the other hand has always baffled me with its attributes and the redundant and verbose tags (why do I need <tag attr="data">data</tag>?). I'm sure there was a good reason at the time for this, so perhaps someone can enlighten me.
- jbooth 14y agoI don't know a lot, but: XML looked like HTML at a time when the web was the "next big thing". Like, not a technology on the web, or social media, HTML itself was this big revelation. So a solution that looks like HTML has a leg up. Then, once there were mature parsers in a lot of languages, server software configured by it, etc, XML had some inertia that takes time to displace.
- TylerE 14y agoJSON conceptually has been around forever. Lisp s-exps date to the original McCarthy paper in 1958, and could represent pretty much everything you can do with JSON, key-value pairs, lists, nested structure, etc.
- duaneb 14y agoHonestly, JSON isn't really much of an improvement over a technology that's been around since 1958, i.e. s-expressions. JSON is just the flavor of the month - I know people who dislike it because it loses some of the power of XML (XSLT, attributes, etc.) In the end, I think it's just subjective. All of the above formats are equally capable of representing the same data.
- quux 14y agoFormats very similar to JSON have been invented many times, for instance NeXT/Apple used to have a human readable format for their plist files that was basically JSON with different characters. http://code.google.com/p/networkpx/wiki/PlistSpec http://code.google.com/p/networkpx/wiki/PlistSpec For some reason they stopped using text plists and replaced it with an ugly xml serialization, but you still see these in Xcode's debugger if you log an NSArray or NSDictionary to the console.
- lmkg 14y agoWhat took the longest time was for a language to come out with key-value maps as the main core data structure, and a specialized literal syntax. Once that happened, it was relatively quick for that syntax to become a standardized interchange format for K-V data. Lisp had assoc-lists, but those were a convention, not a specialized structure. Many languages had K-V maps as libraries, but not core structures, and most lacked literal syntax. Eventually most scripting languages starting getting them as native, and even having literal syntax, but they weren't the "go-to" data structure for doing things. In Python, for example, all of its objects are really just hash maps, but when you're working with them you pretend that they're objects and not hash maps, and you use lists more than maps anyways. JavaScript (and maybe Lua) was the first language to build itself around K-V maps, so it was the first language where idiomatic usage included a lot of map literals. Like Python, its objects were all really just maps, but unlike it encouraged taking advantage of that fact. Also, because it was on the web, there was a lot of need to be serializing data structures and passing them around. Eventually someone realized "this is much better than XML!" and gave it a name, and that's how we got where we are today. XML's popularity is an accident of history, due in part to the rise of HTML, which is also an accident of history.
- chimeracoder 14y ago> Lisp had assoc-lists, but those were a convention, not a specialized structure. I'm not sure what you mean by this. What's the difference, syntactically, between a convention and a specialized structure? XML is Lisp. In fact, the XML grammar and Lisp's grammar are (almost) homomorphic[1]. SXML is a trivial mapping of XML to s-expressions which demonstrates this. There's no point in comparing XML and S-expressions like that; they're essentially the same thing! If you're talking about internal representation, well, that's up to the compiler. But since you have to declare the format either explicitly or by context, there's no 'advantage' of XML over s-expressions. [1] To be pedantic, XML is homomorphic to SXML, which is a subset of the Lisp grammar, but that just means that Lisp recognizes some strings that aren't in the XML grammar, so if anything, Lisp is more powerful, but that's beside the point.
- lmkg 14y ago
- untog 14y agoI've actually always liked the idea of XML at it's core- attributes and so on often make data structures easier to understand (just look at HTML), but namespacing and all that junk ruined the whole thing. The only reason I still use XML every now and then is XPath. There are third-party alternatives for JSON, but XPath is ubiquitous.
- ucee054 14y agoFrom a big data perspective, I'm pretty sure people were making do with CSV files before JSON came along. I think most practitioners would not subject themselves to stupid, stupid XML unless they really had to.