News for hackers. Stuff that matters.
Re:XML is better than YAML by matsemann on Wednesday September 20, 2023 @02:24PM (#37587880)
At least I've never had production errors because of malformed xml. Yaml, though.. A misplaced dash and your list of a single item is suddenly two distinct items instead.
Re:XML is better than YAML by gilcot on Wednesday September 20, 2023 @02:42PM (#37588197)
You're one of those few lucky whose malformed xml cause no issue.
Re:XML is better than YAML by Groxx on Wednesday September 20, 2023 @02:31PM (#37587989)
Whole I definitely agree yaml is pointlessly prone to this ("NO" lol), I've had plenty of xml issues. Bad manual attribute encoding, duplicate attributes (pretty easy when there are lots) that vary in behavior depending on your xml reader, using text content instead of attributes, using lists of text nodes as a map that then gets deduplicated inconsistently instead of attributes (to work around needing to manually encode complex or multi-line text into an attribute)...

Humans can screw up anything. And more text often allows it to hide for longer.

Re:XML is better than YAML by kaba0 on Wednesday September 20, 2023 @02:46PM (#37588266)
But one of them has schema descriptions to prevent these errors as soon as possible.
Re:XML is better than YAML by Groxx on Wednesday September 20, 2023 @03:27PM (#37588840)
Sure, if you define and use it. Same as yaml schemas (they exist!).

XML has them sorta built in (basically all (notable) libraries support them), but it's not like it's required or somehow innately protected because of that. It's just a bit easier to adopt.

Re:XML is better than YAML by matsemann on Wednesday September 20, 2023 @04:51PM (#37590002)
But my case was with a yaml validated to a schema. A kube ingress file with a list of rules. My additional dash made it a new entry, in practice allowing everything. With xml it would have been very explicit that I now accidentally had made two rules.
Re:XML is better than YAML by throwawaymaths on Wednesday September 20, 2023 @07:20PM (#37591344)
> But one of them has schema descriptions

JSONSchema? It's pretty standardized and well accepted.

Re:XML is better than YAML by NBJack on Wednesday September 20, 2023 @07:50PM (#37591590)
I believe XML has it baked directly into the official spec. JSONSchema is great, but I wouldn't call it a standard yet, and anecdotally I haven't seen it as often as I'd like in use (i.e. I either need to run kubectl --dry-run or use a separate third party solution to validate my changed yaml).
Re:XML is better than YAML by meepmorp on Wednesday September 20, 2023 @08:20PM (#37591777)
XML schema is a separate spec.
Re:XML is better than YAML by kaba0 on Thursday September 21, 2023 @01:42AM (#37593613)
Read the title - just because YAML is a superset of JSON, doesn’t mean you can check every YAML file with JSOnSchema.
Re:XML is better than YAML by EddTheSDET on Wednesday September 20, 2023 @02:37PM (#37588104)
I once had an issue where something failed in prod but not in test, it was because a MAC address was dynamic and in prod only consisted of numbers so whatever tool we used parsed the Yaml value as a sexagesimal number and threw a type error. Yaml can be interesting…
Re:XML is better than YAML by dragonwriter on Wednesday September 20, 2023 @07:29PM (#37591434)
Note that the behavior you describe (like the “NO” problem) was part of the YAML 1.1 excessive-effort-at-DWIM insanity (in this case, intended to make time entry “just work”) that was removed in YAML 1.2.
Re:XML is better than YAML by nikanj on Wednesday September 20, 2023 @02:29PM (#37587961)
Malformed xml sneaks through the kitchen window and poisons you in your sleep. Someone puts naively escaped umlauts (ä -> ä ) into the surname field and your entire xml parser borks with unknown entity errors
Re:XML is better than YAML by kstrauser on Wednesday September 20, 2023 @02:44PM (#37588230)
Pro tip: remember that all JSON is valid YAML. You can put JSON in a .yaml file and be just fine. I find that handy when the explicitness makes it easier to read the file.
Re:XML is better than YAML by marcosdumay on Wednesday September 20, 2023 @10:19PM (#37592547)
As long as you remove all the indenting.

All JSON evaluates to some value in YAML. But it's not always the value you want it to.

Re:XML is better than YAML by throw__away7391 on Wednesday September 20, 2023 @10:59PM (#37592744)
I have. A ton of vendors and APIs generate XML with interpolation or some other form of hand-rolled code that’s incorrectly escaped, which compliant parsers can’t parse and they can’t fix.
Re:XML is better than YAML by KronisLV on Thursday September 21, 2023 @04:49AM (#37594934)
> At least I've never had production errors because of malformed xml.

Oh hey, I had some while making https://hn-blogs.kronis.dev/

I wrote more about it on my blog: https://blog.kronis.dev/articles/ever-wanted-to-read-thousan... but the gist of it is that I had to parse thousands of blog feeds and some article from 2009 included a SOH control sequence inside of otherwise valid XML and this broke everything, until I added additional error handling.