| ▲ | dale_glass 7 hours ago | |||||||||||||||||||||||||
It kinda blows my mind that after XML we've managed to make a whole bunch of stuff that's significantly worse for any serious usage. JSON: No comments, no datatypes, no good system for validation. YAML: Arcane nonsense like sexagesimal number literals, footguns with anchors, Norway problem, non-string keys, accidental conversion to a number, CODE INJECTION! I don't know why, but XML's verbosity seems to cause such a visceral aversion in a lot of people that they'd rather write a bunch of boring code to make sure a JSON parses to something sensible, or spend a day scratching their head about why a minor change in YAML caused everything to explode. Actually my own problem with XML was annoyance that back when I had the thought of doing a complex config format in XML, the idea of modifying it programmatically while retaining comments turned out to be absolutely non-trivial. In comparison with the mess one can make with YAML that's just a trivial thing. | ||||||||||||||||||||||||||
| ▲ | ACCount37 7 hours ago | parent | next [-] | |||||||||||||||||||||||||
"Any serious usage" starts at "it just works". JSON just works. Every language worth giving a damn about has a half-decent parser, and the syntax is simple enough that you can write valid JSON by hand. You wouldn't hit the edgy edge cases or the need to use things like schemas until down the line, by which point you're already rolling with JSON. XML doesn't "just work". There are like 4 decent libraries total, all extremely heavy, that have bindings in common languages, and the syntax is heavy and verbose. And by the time you could possibly get to "advanced features that make XML worth using", you've already bounced off the upfront cost of having to put up with XML. Frontloading complexity ain't great for adoption - who would have thought. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
| ▲ | catlifeonmars 4 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
> Actually my own problem with XML was annoyance that back when I had the thought of doing a complex config format in XML, the idea of modifying it programmatically while retaining comments turned out to be absolutely non-trivial. In comparison with the mess one can make with YAML that's just a trivial thing Only relatively few parsing libraries preserve the token stream metadata in the AST, most don’t even expose the AST. For the former, I can understand why, it’s a cross-cutting concern and adds complexity to the AST parse, but is almost always worth it. | ||||||||||||||||||||||||||
| ▲ | n_e 7 hours ago | parent | prev [-] | |||||||||||||||||||||||||
> JSON: No comments, no datatypes, no good system for validation. I don't agree at all. With tools like Zod, it is much more pleasant to write schemas and validate the file than with XML. If you want comments, you can use JSON5 or YAML, that can be validated the same way. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||