Re:YAML: Probably not so great after all
by cygned on Sunday August 18, 2019 @02:54PM
(#20732096)
Is there an agreement on whether it’s
or
yet?
[ Parent
| on HN ]
Re:YAML: Probably not so great after all
by tannhaeuser on Monday August 19, 2019 @02:00AM
(#20735248)
Yes there is. Markup languages are for representing rich text. Anything that gets rendered to the user is content and anything that's metadata (data about how to render) but not rendered as such goes into attributes. If there is no concept of "rendering to the user" in your app/data, then markup isn't the right choice for representing your data. You're blaming markup languages for not being designed to represent arbitrary data structures when you should be blaming yourself for misusing and misunderstanding markup. Though by skimming through this thread, XML appears to still do much better than YAML. And it's true that in the 00's, XML was improperly used and advocated as universal data format.
That is a reasonable approach - thanks.
Attributes are XML’s foot-gun.
Particularly annoying is that there's no way to do lists with attributes. Looks good:
<user name="alice" group="wheel" />
Oh no: <user name="alice" groups="wheel admin sudoers" />
Or is it one of: <user name="alice" groups="wheel,admin,sudoers" />
<user name="alice" groups="wheel:admin:sudoers" />
<user name="alice" groups="wheel;admin;sudoers" />
Or give up and use elements: <user name="alice">
<group>wheel</group>
<group>admin</group>
<group>sudoers</group>
</user>
Hold on, should there be a container? <user name="alice">
<groups>
<group>wheel</group>
<group>admin</group>
<group>sudoers</group>
</groups>
</user>
XML really needs either richer attributes, or no attributes.Replace with "Element" with "Class" and "Attribute" with "Property" in your examples.
It's your job to decide how the data should be structured, in any language.
I would do the following :
<user name="alice">
<groups>
<group uid="wheel"/>
<group uid="admin"/>
<group uid="sudoers"/>
</groups>
</user>Attributes are XML’s foot-gun.
I disagree. Back in the day we used attributes for everything that was key value and inner tags for anything with structure. We also formatted for clarity:
<lunch
env="outside"
food="sandwiches"
drink="cola"
/>
Compared with what we used to do, I look at attribute-less maven pom.xml with horror.The decision of when and how to use attributes is the thing that is most often done wrong or clumsily in an XML file. That is my point.
Re:YAML: Probably not so great after all
by johnchristopher on Sunday August 18, 2019 @04:04PM
(#20732486)
What if it's to be used by french speaking software/people ?
<lunch
env="outside"
envfr="dehors"
food="sandwiches"
foodfr="sandwichs"
drink="cola"
/>
Or <lunch
env="outside"
food="sandwiches"
drink="cola">
<label type="env" language="fr">Dehors</label>
<label type="env" language="de">Außenseite</label>
<label type="env" language="en">Outside</label>
</lunch>
Quite curious about it.I guess this way:
<lunch
env="outside"
food="sandwiches"
drink="cola">
<label xml:lang="fr">Dehors</label>
<label xml:lang="de">Draußen</label>
<label xml:lang="en">Outside</label>
</lunch>
says[0]the w3.
Re:YAML: Probably not so great after all
by johnchristopher on Monday August 19, 2019 @11:40AM
(#20738710)
I see, thanks. (I also see you corrected my broken German ^^).
Putting l10n/i18n data inline is generally not a pleasant experience, and this problem persists regardless of what serialization format you are using. Either have separate data files per-locale that are merged with the defaults or store the localized strings in a central location (ala your usual gettext setup).