4 ms·
An important one is that XML does not map cleanly to any programming language's typical data structures, even those that explicitly support it. It always turns
by johnbm 13y ago
An important one is that XML does not map cleanly to any programming language's typical data structures, even those that explicitly support it. It always turns into an elaborate object hierarchy with awkward query syntax. The combination of unique named string-only attributes with ordered, non-unique named child objects is awkward and ambiguous (i.e. should that property be an attribute, or a child?). Contrast for example with JSON, which translates directly into arrays and hashes, structures available in any decent language.
E.g. you have <user name="john" address="123 Oracle Road"></user>
Now you decide you need multiple addresses per user. Do you: a) invent an ad-hoc string serialization scheme for the address="" property, or b) completely restructure your XML into:
<user name="john">
<address>123 Oracle Road</address>
<address>456 XML Lane</address>
</user>
But in that case, why not just make every property a child?
XML also spawned idiotic things like XSLT, which most agree is pretty terrible. If you try to use XSLT for HTML templating, by definition you have to escape every meaningful HTML character like "<>&'". If you wish to print one of those characters in your templates, you have to double escape them. No designer I know of would touch it with a ten foot pole, and every programmer I've met who loved XML and its associated technologies was terrible at their job.
Basically XML is strongly associated with the bloaty enterprise Java world, who used XML as their hammer to beat down anything remotely nail-like.
- slashnull 13y agoHa! Excellent. Thank you.
- brudgers 13y agoAs a tree, XML syntax is largely isomorphic with that of Lisp's exposed AST.
- slashnull 13y agoWell, yeah, but XML has attributes. I was writing about how that was a problem and so on, but I came up with this <look attr="at" attr2="up"> this <awkward> problem </awkward></look> (look (|attr at) (|attr2 up) this (awkward problem)) just by saving "|" as a meta to annotate an attribute pair. And the weird problem of lone tags looking like unclosed ones magically flies away (I think) since <script type="text/javascript" src="foo.js" {">", "/>", "></script>"} is just (script (|type text/javascript) (|src foo.js)) ...sometimes I wonder why isn't everything ever made out of S-exprs.
- brudgers 13y agoLisp has keywords: (look #:attr "at" #:attr2 "up" this (awkward problem)) Or to handle XML on the fly, cons cells are another option: (look '(attr . "at") '(attr2 . "up) this (awkward problem)) Going further since it's Lisp and we're just parsing, we could pretty much use whatever syntax we want by adding a macro: (look (attributes attr "at" attr2 "up") this (awkward problem))