this post was submitted on 09 Sep 2024
424 points (95.9% liked)
Programmer Humor
19564 readers
946 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
XML is a superior format to Json or yaml or any of those other trendy formats around today. It's the hill I'm willing to die on because I'm right.
XML aims to be both human-readable and machine-readable, but manages neither. It's only really worth it if you actually need the complexity or extensibility, otherwise it's just a major pain to map XML structures to any sensible type representation. I've been forced to work with some of the protocols that people like to present as examples of good XML usage and I hate every single one of them.
Fuck YAML though. That spec is longer and more complex than any other markup language I know of and it doesn't have a single fully compliant implementation.
I'm okay with the "human-readability," but I've never been happy with the "machine-readibility" of XML. Usually I just want to pull a few values from an API return, yet every XML library assumes I want the entire file in a data structure that I can iterate through. It's a waste of resources and a pain in the ass.
Even though it's not the "right" way, most of the time I just use regex to grab whatever exists between an opening and closing tag. If I'm saving/loading data from my own software, I just use a serialization library.
Yep, it's a PITA to parse and get the values you want. Much prefer JSON. Recently when I needed to parse XML I ran it through an XML to JSON library. Much easier!
If you need to parse XML just for RSS though, it isn't so bad as there are RSS specific libraries which take most of the pain away.