Live data from Hacker News

Why is JSON so popular? Developers want out of the syntax business

blog.mongolab.com

51–60 of 133 posts

Re: Why is JSON so popular? Developers want out of the syntax business

#51
JSON is so popular because it's data description abilities are poorer than that of XMLs. Everything in JSON can be easily mapped to a few basic types in any popular language, and so all the JSON writers/readers do exactly that. The consequence is that it's very easy to work with JSON.

Contrast with XML, which has node attributes and children, to start with. This alone is sufficient to make it not as naturally representable in any of the languages (Python's ElementTree does come close), so you have to worry about the "syntax". And that's not even considering namespaces or schema.

XML having a much richer way to represent data and to reason about the meaning of the data make it a good format for case where it is important. But for everything else, JSON wins.

Re: Why is JSON so popular? Developers want out of the syntax business

#52

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

Heh, I'm embarrassed to admit that the protocol-buffer system I'm using at work looks kind of like that. Our most common message types contain a repeated field, each one holding a name value pair, instead of just containing a list of non-required fields

I'm embarrassed because I was the lead designer of said system. In my defense, protobufs had just been open-sourced, and it was my first time using them. I thought that name/value pairs would give me greater flexibility. We're using a dynamic language, and I though re-compiling the .proto files every time I added a new item would be a pain. It turns out that there's still a file somewhere in the system listing all the valid names, so we could have just as easily put the list of valid names into a .proto file, and avoided sending the names over the wire with every message, and saving them in every log record, etc. Our build system is sufficiently well automated that recompiling the .protos is painless and almost unnoticeable.

Oh, well, maybe someday I'll get around to redoing our protocol. Fortunately, it's purely internal, and we don't yet store long-lived data in that format, so there's still hope.

Re: Why is JSON so popular? Developers want out of the syntax business

#53

Earlier quoted context omitted.

Use protocol buffers! As easy to use as JSON in dynamic languages, gives you strongly-typed accessors in static languages.

Yeah... no. I'm not a big code gen guy. But the google people seem to love them, so I'm probably in the minority.

> Yeah... no. I'm not a big code gen guy.

Me either! Which is why I'm working on a high-performance Protocol Buffer library that does not do code generation: https://github.com/haberman/upb/wiki

Re: Why is JSON so popular? Developers want out of the syntax business

#54

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

I think the difference is that XML protocols are meant to be generated while JSON protocols are meant to be hand-written to some extent.

Otherwise, what's the difference with:

{'ret': 'pump me up'}

And

pump me up

If it's a computer generating it?

Re: Why is JSON so popular? Developers want out of the syntax business

#55
post #54

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

I think the difference is that XML protocols are meant to be generated while JSON protocols are meant to be hand-written to some extent. Otherwise, what's the difference with: {'ret': 'pump me up'} And pump me up If it's a computer generating it?

huh? thats not the motivation or intent of either format's design.

Re: Why is JSON so popular? Developers want out of the syntax business

#56
post #54

Earlier quoted context omitted.

I think the difference is that XML protocols are meant to be generated while JSON protocols are meant to be hand-written to some extent. Otherwise, what's the difference with: {'ret': 'pump me up'} And pump me up If it's a computer generating it?

huh? thats not the motivation or intent of either format's design.

Replace "hand-written" and "machine generated" with "human consumption" and "machine consumption"

Re: Why is JSON so popular? Developers want out of the syntax business

#59
post #7

Ironically, php provides a way to access XML data almost as easily as JASON data - SimpleXML. Do other languages/frameworks really have nothing similar?

Only problem with SimpleXML is that it needs to have the complete file in memory. This isn't a problem for small XML files. But reading a file of lets say 100MB will produce tons of objects an thus a large amount of used memory.
Post reply on HN