Remix.run Logo
hnlmorg 5 hours ago

It isn’t incompatible. It’s just a massive superset of what is needed.

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.

dvdkon 5 hours ago | parent [-]

I don't think it's a superset. You can represent any structs-and-arrays data in XML, but you have to make non-trivial mappings to make it work.

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.

hnlmorg 5 hours ago | parent | next [-]

That’s why it’s a superset ;)

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.

dvdkon 17 minutes ago | parent [-]

Eh, XML is as much of a superset of JSON as the Turing machine is a superset of context-free grammars. The former has all the _power_ of the latter and more, but the mapping between them is non-trivial, far from an embedding.

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.

lolive 4 hours ago | parent | prev [-]

Watch how dict2xml or xml2dict handle JSON to XML automatic mapping. Both format carry 99% of the same structural infos in their respective serialization.