3 ms·
> Millions of developers use XML all the time, it's called HTML. HTML is not XML and even then few developers today use HTML without some sort of processing in
by gridlockd 8y ago
> Millions of developers use XML all the time, it's called HTML.
HTML is not XML and even then few developers today use HTML without some sort of processing involved. HTML is also not a language used for configuration files, so it is really off-topic.
The question is, do people prefer XML configuration over JSON configuration. The answer is that people generally prefer JSON. JSON just maps far better to data types we use in everyday programming. Have you seen some of the common ways of expressing key-value pairs in XML? It's horrible.
> Now try taking a typical HTML document and expressing it in JSON.
That's not the problem anybody is trying to solve here. We're talking about configuration files, not complex documents. But let's say I wanted to solve that problem, the representation would look like this:
http://www.jsonml.org/ http://www.jsonml.org/
Not that bad at all.
- joezydeco 8y agoWell put. Thank you. In my world, config files are machine-parsed but human-generated and modified. JSON is just easier to work with.
- manigandham 8y agoIt's a technical distinction without a practical difference. They are both declarative languages to describe data. Why is it so horrible? Have you ever typed a <ul><li> list? Or <input name="key" value="value">? What exactly is so difficult about this syntax in XML but completely fine in HTML? The point isn't whether you can represent a document in JSON, it's about how easy it is for a human to manage it. The XML/HTML structure is far easier as things get more complex. The page you linked to shows this quite clearly even with the small "Bulleted List Example" at the bottom.
- SllX 8y agoHTML is distinctly not XML. There is XHTML if you want to use a form of HTML that is processed like XML, but XML processing is a lot stricter than HTML processing in which you can take a lot more liberties in the markup and still end up with a readable result, maybe even what you intended, whereas an XML processor will usually refuse to render incorrect XML markup at all.
- bauerd 8y ago>They are both declarative languages to describe data. This still applies then
- manigandham 8y agoI'm comparing the data structure and editing ergonomics (which are identical) between XML and HTML, not how they are processed. It's good for config files to have precise parsing instead of tolerating errors.
- gridlockd 8y ago> It's a technical distinction without a practical difference. There's a lot of practical differences when actually implementing configuration with either XML or JSON, due to technical distinctions. > The point isn't whether you can represent a document in JSON, it's about how easy it is for a human to manage it. If XML is easier to manage, why are people shifting from XML and to JSON for configuration? You may have some experience with HTML, but have you actually used some of these XML abominations that are used for configuration? > The XML/HTML structure is far easier as things get more complex. Configuration files shouldn't be complex. They're mostly key-value pairs, perhaps a couple of lists here and there and a modest amount of nesting. XML is complex to begin with. Perhaps at some stage, for some use-cases, XML starts becoming simpler to edit. Configuration files generally isn't one of them. > The page you linked to shows this quite clearly even with the small "Bulleted List Example" at the bottom. It's an example of representing XML-like structure with JSON, which is fairly easy. Try it the other way around, things get hairy. If you were to represent the data as JSON, you wouldn't write it like that.
- manigandham 8y agoIf config is small, both formats are easy and it doesn't matter. When config is large and complex then both formats can be hard, however XML is much easier than JSON as complexity climbs. My evidence is how many people easily edit large complex document structures in HTML already without issue. I'm just not sure what the argument against this is other than verbosity. Config files shouldn't be complex? Sure, but what if they are? Are people really moving to JSON everywhere or is it just tied to the rise of Javascript and web frameworks?
- gridlockd 8y ago> 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.