1. 7
  1. 4

    This a long-standing discussion. You may want to read Paul Prescod’s XML is not S-expressions to see why this is subtley wrong and not really the best of ideas.

    1. 2

      Thank you for sharing that link, that was the first time I’ve noticed someone speaking out against using S-expressions for HTML/XML. I’d disagree and say that S-expressions are easier to work with and there exist something like Scribble for documentation in Racket.

      1. 1

        There are also strong mappings like SXML

      2. 2

        I’ve been generating HTML from S-expressions for decades and I’ve got to say none of the downsides mentioned in the article have ever come up. Being able to use tools like paredit for authoring documents is a huge leap over the editing tools I’ve tried that are available for HTML.

        Granted I’m typically using an s-expression flavor which allows for key/value data structures with {} since I do kind of agree that forcing associative data into parens isn’t very clear.

        The XML one defaults to treating random characters as text, not as markup.

        This might be considered an advantage when you’re just manually authoring documents directly, but when you’re writing application code that emits HTML (which is the case in the original article) this property is very bad.

        In the S-expression version, the software does not know that there is a missing parenthesis until it gets to the end of the document. […] Smart editing tools can help but the cannot solve the problem.

        Incorrect; paredit and other structural editors completely solve this.

        the canonical documentation of the Scheme and Lisp standards is maintained not in S-expression syntax but in LaTeX

        This is a simple case of bootstrapping; you can’t define something using the thing that’s in the process of being defined. Obviously bootstrapped lisps do exist, you always have to have some starting point for a bootstrap.

        DTDs, RELAX and XML Schema define constraints on individual instances of XML documents.

        I guess Clojure spec didn’t exist when this document was written, but it does now.

        1. 1

          Not having to escape quotes in XML was the killer feature for me over Sexps.

          (Well, that and inline markup.)

        2. 2

          This approach is also one of the core ideas behind a book-publishing domain-specific language called Pollen, which is written in Racket. The documentation also dives a bit into the relationship between S-expressions and HTML.

          1. 0

            HTML doesn’t fit because it has both attributes and children.