3 ms·
Attributes are intended to hold metadata, not data. It's not the fault of the format if someone chose to use it in a poor way. You also need to distinguish the
by HarHarVeryFunny 4mo ago
Attributes are intended to hold metadata, not data. It's not the fault of the format if someone chose to use it in a poor way.
You also need to distinguish the format itself from the various libraries that may be available to parse/process it in a given language. It doesn't always make sense, even when it's an option, to let the tail wag the dog and choose a language just because it has a nice library for something.
> Furthermore parsing JSON or YAML gives you the basic data types like lists and dictionaries
Well, maybe some library for some language does that, and if that is the language you are using, and that is all you need, then I suppose you are in luck. More generally you may want to use a format like XML or JSON to hold user defined types, which rather levels the playing field since there are few good libraries for this in any language,and you may need to roll your own (been there, done that).
- tpm 4mo ago> It's not the fault of the format if someone chose to use it in a poor way. Which is why we've ended up with things like WSDL which define another layer on top of XML to make it actually usable for the thing it is used for. Hence the collective exhale when JSON showed up.
- inigyou 4mo agoAgain we come back to it being a markup language. In markup, it's usually pretty clear what is data and metadata: <font style="bold">hello world</font> and not <font><style>bold</style>hello world</font> because you don't want the word "bold" to literally appear in the document. In structured data, the distinction is redundant.
- HarHarVeryFunny 4mo agoNot always. For example, XML itself doesn't have types, so maybe you need to use attributes to store the data type (e.g. what if you need to do to lossless JSON <-> XML conversion).
- inigyou 4mo agoand what is the difference between <data type="dict"> and <data><type>dict</type> and <dict>?
- HarHarVeryFunny 4mo agoIf you use tag "type" rather than attribute "type", then you are going to clash with representing data that itself needs to use tag "type".