Indeed, I often feel that XML documents, when compared with equivalent YAML files, demonstrate all the grace and calm reserve of a Pee-wee Herman chase scene (complete with rope swing, speedboat, sleigh, and man in a Godzilla costume).
That’s a quote from this book by AndrĂ© Ben Hamou, and it’s pretty much exactly how I feel about data serialisation. YAML has become my go-to format for just about everything. Why I love YAML:
- It’s really easy to map out and visualise complex data structures, especially in languages like Perl where this can be a bit of a pain.
- It’s completely cross-platform. so I can transport stuff between all the languages I write (yeah, OK, both of them if you don’t count 37 dialects of shell).
- It’s safe — no eval required
- Once your code is built to marshal/unmarshal using YAML, adding support for more formats (JSON, XML, language-native formats) is a piece of piss.
I will never write a config file parser again, nor hinky semi-structured report formats.