Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If config is small, both formats are easy and it doesn't matter.

Even if I would agree with this (which I don't), if it doesn't matter then you should pick JSON because it's easier to work with as a developer and it doesn't require XML parsing as a dependency.

> My evidence is how many people easily edit large complex document structures in HTML already without issue.

This isn't evidence at all. An HTML document is not a configuration file. Even then, people rarely author large HTML documents by hand these days. It's more likely that they're using a simpler language like Markdown to author documents.

> Are people really moving to JSON everywhere or is it just tied to the rise of Javascript and web frameworks?

If Javascript and web frameworks are responsible for the rise of JSON, but XML is better, why didn't they stick with XML? Remember, SOAP was XML. AJAX stands for "asynchronous Javascript and XML". The way to do an HTTP request (before fetch) from Javascript was called (inappropriately) XMLHTTPRequest. JSON on the other hand was just an informal spec with several flaws, yet it won out over XML.



1) What I mean by "it doesn't matter" is that at small scale, neither one easier than the other.

2) JSON does need to be parsed and does add a dependency. Javascript is not the only language out there.

3) HTML not being config files is not the point. The document/tag structure is identical. If you can edit large complex HTML files (regardless of how they are generated) then you can edit large complex XML files. And it's rather easy to do so, against the claims that XML is so hard to work with.

4) There are plenty of XML configs out there, backing just about every piece of software you use. If you only focus on web/js projects then JSON "won out" because it is a simple dump of the in-memory representation rather than a more formal serialization like XML. The missing features like JsonPath and Json Schema are now being added back to turn it into a proper serialization format. When storing configs, these schema features are rather important.


1) Yes, if they're both easy to use, pick JSON - for simplicity's sake.

2) A JSON parser is a far smaller and simpler dependency than an XML parser, especially when we're adding XPath to the mix.

3) XML isn't necessarily hard, it's tedious.

4) There's plenty of legacy software out there using all kinds of stuff for config. You don't see a lot of people choosing XML these days. You see YAML or TOML or JSON, even though all of these have issues of their own. JSON happens to be the simplest and most commonly supported.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: