

Revisiting the XML Angle Bracket Tax - bdfh42
http://www.codinghorror.com/blog/archives/001139.html

======
Hexstream
As a lisp weenie, I feel it is my duty (yes, I have a strong sense of
entitlement ;P) to ask:

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.

~~~
olavk
Yes, XML syntax is better for writing and editing structured human-readable
documents. eg. something like XHTML. The attribute/element dichotomy also
makes a lot of sense in that context.

Regarding structured machine-generated data (which is where XML actually is
used most today), s-expressions are arguably simpler.

~~~
Hexstream
"Yes, XML syntax is better for writing and editing structured human-readable
documents. eg. something like XHTML."

    
    
      (: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>

~~~
olavk
The redundant end tag is a feature which makes it easier to write and edit by
hand. E.g. imagine you have a <section> of text more than a screenfull - how
do you see when the section ends? Which closing parenthesis is it? This is an
important feature because document are often large, deeply nested structures.

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.

~~~
Hexstream
In most documents, the number of tags that fit in a screenful __completely
__dwarfs the number of tags that don't. So it makes sense to optimize for the
former case. And I don't think forcing redundance everywhere is a proper way
to "make it 'easier' to edit".

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.

