JSON
JSON is so hot right now. It's a superior alternative to XML for many reasons:
- It's shorter, since there's no need for end tags, etc.
- There's no futzing about with namespaces.
- It's not based on SGML, the ugliest, hardest to type language in the universe.
- It's almost immediately parseable in Javascript, and closely resembles constructs found in other languages (i.e., nearly a one-to-one mapping).
And so forth. It's practically the second coming.
But it's not without its shortcomings...
- JSON doesn't support comments, so is pretty much a write-off for any sort of configuration file. Just bloody skip them! (Some parsers do this anyway.)
- JSON forces the arbitrary decision to use double quotes '"' to the exclusion of single quotes "'" to denote a string. JavaScript proper doesn't have this limitation. Personally, I use single quotes wherever possible for the simple reason that they're easier to type. Especially when...
- JSON forces you to mark object keys explicitly as strings, wrapping them in double quotes. In JavaScript, a key that's a valid identifier needn't be quoted. It's just extra typing.
- JSON doesn't let you write an extra comma to separate array/object items. In Python, this is perfectly acceptable, and for at least one excellent reason: it's simpler for machines to generate. Otherwise, you end up with an inevitable "if this is not the last element, write a trailing comma" in all your for loops. Gross.
(To be continued...)