The lost art of XML — mmagueta

https://programming.dev/post/44564394

The lost art of XML — mmagueta - programming.dev

> There exists a peculiar amnesia in software engineering regarding XML. Mention it in most circles and you will receive knowing smiles, dismissive waves, the sort of patronizing acknowledgment reserved for technologies deemed passé. “Oh, XML,” they say, as if the very syllables carry the weight of obsolescence. “We use JSON now. Much cleaner.”

I love XML, when it is properly utilized. Which, in most cases, it is not, unfortunately.

JSON > CSV though, I fucking hate CSV. I do not get the appeal. “It’s easy to handle” – NO, it is not.

JSON is a reasonable middle ground, I’ll give you that

CSV >>> JSON when dealing with large tabular data:

  • Can be parsed row by row
  • Does not repeat column names, more complicated (so slower) to parse
  • 1 can be solved with JSONL, but 2 is unavoidable.

    { "columns": ["id", "name", "age"], "rows": [ [1, "bob", 44], [2, "alice", 7], ... ] }

    There ya go, problem solved without the unparseable ambiguity of CSV

    Please stop using CSV.

    Great, now read it row by row without keeping it all in memory.

    Wdym? That’s a parser implementation detail. Even if the parser you’re using needs to load the whole file into memory, it’s trivial to write your own parser that reads those entries one row at a time. You could even add random access if you get creative.

    That’s one of the benefits of JSON: it is dead simple to parse.