8 ms·
Umm, no. You can find cases where JSON sucks, but you have to look for them. You can find cases where XML doesn't suck, but you have to look for them.
by gweinberg 7y ago
Umm, no. You can find cases where JSON sucks, but you have to look for them. You can find cases where XML doesn't suck, but you have to look for them.
- michaelmrose 7y agoOther than looking ugly and being a pain to type does xml actually suck?
- jsjohnst 7y agoDepends on the XML. When you start mixing in namespaces (like trying to parse Maven pom.xml files in Python), it quickly becomes a mess.
- jamougha 7y agoNamespaces are horrible in Python because the Python XML libraries are deficient. They're generally fine in e.g. Java. (Unless you're trying to represent QName typed data, but that's very niche.)
- jsjohnst 7y agoI used Python as an example, but handling namespaces in most languages besides Java (and even arguably in Java depending on your point of view) is rather painful.
- tomc1985 7y agoI'd say the same about JSON!
- t-writescode 7y agonamespaces are absolutely a bear and always unpleasant to work with. The libraries to use xml are equally frustrating when you’re doing complicated things, unless you want to make a class for every single type of detail that this xml document wants - then it’s fine, but some of us don’t want to do that, or inherited a project that didn’t do that. XPath is a struggle with namespaces, as well. It’s ... trying.
- Nevermindmine 7y agoHow is that relevant for config files though? If you implement an app and want to use a config file, you don't have to use namespaces. I agree that namespaces are no fun, so I don't use them for my config files.
- wokkel 7y agoNamespaces are great when used wisely: they allow for embedding unrelated XML fragments in your document and your application will not see them. Or versioning your XML in namespaces. XPath and namespaces are trivial but it depends on the library you use on how to setup the namespace resolving. My pet peeve about namespaces: people that use HTTP URLs for their declaration and expecting them to be resolved for some reason. The other one being people that see a namespace prefix and think that that is the actual namespace.
- cygned 7y agoIs there an agreement on whether it’s <author name="pete" /> or <author> <name>pete</name> </author> yet?
- dbcurtis 7y agoAttributes are XML’s foot-gun.
- papaf 7y agoAttributes 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.
- johnchristopher 7y agoWhat 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.
- snuxoll 7y agoPutting 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).
- yosamino 7y agoI 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. [0]https://www.w3.org/TR/REC-xml/#sec-lang-tag https://www.w3.org/TR/REC-xml/#sec-lang-tag
- dbcurtis 7y agoAny time the semantics represented by the XML is non-trivial, the schema design is likely to be obtuse and/or broken, even when done by smart people. XML is just hard to get right, and hard to evolve gracefully. When you add verbosity on top of that, working with XML over the long haul is an utter pain.
- wbl 7y agoNumbers over 2^52. Unicode. Terminator vs. Separator. Weak type system no DTD. No Xpath equivalent. No namespaces.
- Xylakant 7y agoDate representations. No comments. Behavior when multiple instances of the same key occur.