XML is absolutely fine for data that maps naturally to it. For example text markup. While HTML technically is not XML, it's very close to it and XHTML still is a thing. Probably most people wouldn't enjoy using JSON to encode HTML pages.
XML is absolutely fine for data that maps naturally to it. For example text markup. While HTML technically is not XML, it's very close to it and XHTML still is a thing. Probably most people wouldn't enjoy using JSON to encode HTML pages.
Probably yeah, but also, people don't know how enjoyable it is to just use lists and elements within it to represent HTML. Hiccup is a great example of this where you can do something like:
[:h1 "Hey"
[:strong
{:style {:color "red"}}
"there"]]
And it just makes sense. I'm sure we've yet to find the best way of writing HTML.I'm not so sure about this. When you have a schema it becomes possible to generate your object code, and then your only immediate interface with the XML file is a rather simple instruction to unmarshal it, the rest of the time you're dabbling within your programming language of choice.
Another way to say this is XML is a grammar formalism that deals purely with serialisation rather than higher-level structures that might be serialised such as co-inductive data structures.
> While HTML technically is not XML, it's very close to it and XHTML still is a thing.
XML and HTML-as-serialisation-format are both subsets of SGML.
JSON offers simplicity
YAML offers readability
XML offers a massive feature set.
For what we need 99% of the time, simplicity and/or readability is a much higher requirement.
As for TOML, I honestly don’t understand why anyone likes that.
The obvious way is to use elements for everything, but then you're mapping both structs and their fields (very different concepts in e.g. C) to elements. Attributes map nicely to struct fields, but they only admit string values.
You can map anything to it but that flexibility means you then need to define schemas et al to ensure compliance
The schema thing isn’t actually unique to XML either. you can do the same thing with JSON and YAML too. But in my opinion, if you get into the realm of needing schemas in JSON then you’re at the point where you shouldn’t be using JSON any longer since you’re now violating the “simplicity” argument which is JSONs only real advantage over other formats.
I think it's fine to say C#'s data model is a superset of Java's or Rust's a superset of C's, but XML and JSON is too far for me, personally.
This was in response to a comment that said XML was incompatible with such abstractions.
To be clear, I am not being snide and would be interested in the cases you’re thinking of.