Revisiting the XML Angle Bracket Tax
codinghorror.com
codinghorror.com
Does XML ever have anything over s-expressions, anytime?
As one point, I sometimes struggle with the attribute/nested-tag dichotomy of XML. Sometimes any of them would make sense. Other times, it really looks like it should be an attribute but since the value is more complex than a string I have to use a nested tag.
With s-expressions those issues just don't seem to come up.
That's for C, but since all languages have a C function interface, it shouldn't be impossible to hook it up to your dynamic or static language of choice.
Regarding structured machine-generated data (which is where XML actually is used most today), s-expressions are arguably simpler.
(:html
(:head (:title "I like s-expressions better to read and write XHTML."))
(:body
(:h1 "Some advantages of s-expressions")
(:ul (:li "Not having a redundant end tag is a " (:strong "HUGE") " improvement.")
(:li "Parentheses are nicer than angle brackets " (:acronym :title "in my humble opinion" "IMHO") "; they're also easier to type on most keyboard layouts.")
(:li "You have more room to extend the language, for example having complex attributes."))))
<html>
<head><title>I like s-expressions better to read and write XHTML.</title></head>
<body>
<h1>Some advantages of s-expressions</h1>
<ul>
<li>Not having a redundant end tag is a <strong>HUGE</strong> improvement.</li>
<li>Parentheses are nicer than angle brackets <acronym title="in my humble opinion">IMHO</acronym>; they're also easier to type on most keyboard layouts.</li>
<li>You have more room to extend the language, for example having complex attributes.</li>
</ul>
</body>
</html>Parentheses may seem nicer than angle brackets if you are used to Lisp (C programmers probably think curly brackets are clearly nicer), but note that you are replacing the angle brackets with parentheses and quotes, both which have to match. So it is at least twice as tricky and error-prone to write by hand, and the quotes are less visually helpful since they don't have "direction".
Of course any of these problems can be alleviated by a fancy editor, but XML was intended to be writable and editable without special software.
XML is of course just as extensible, since you use elements for complex structures, not attributes.
S-expressions work fine in Lisp, but programming code is differently structured than documents. For example, in code you typically (hopefully!) don't have several screens of code deeply nested.
You seem to worry about counting closing parentheses but with s-expressions you don't count parentheses. You just look at indentation and the structure emerges.
I just don't buy the "XML should be writable without a proper editor" argument. Why optimize for the couple clueless fools that will try to edit it in NotePad if it hampers the work of the tons of people who actually need to edit lots of XML and actually use a proper editor? Using a proper editor also fixes the undirected quotes problem. Besides, s-expressions might even work better than XML in NotePad because you don't have to indent the end tag because it's just a closing parenthesis that you don't indent.