News for hackers. Stuff that matters.
Re:Major mode for editing SEML (S-Expression Markup Language... by txru on Monday June 03, 2019 @12:41AM (#20080461)
If you have time, this[0] is the canonical article usually shared around this concept. The thrust of it is that yes, XML (or x-expressions) and s-expressions are very similar, and that s-expressions are a less verbose and simpler way to represent data.

[0] https://www.defmacro.org/ramblings/lisp.html

Re:Major mode for editing SEML (S-Expression Markup Language... by js8 on Monday June 03, 2019 @03:57AM (#20081243)
Actually, there is a fundamental difference between XML and sexps. In XML, text is unescaped, while the metadata are escaped. In sexps, the metadata are unescaped, while the text is escaped.

Most text formats fall into one of these two categories. Formats primarily for storing text (like XML or SGML or TeX) are in the former, formats primarily for storing (unstructured) data (like sexps or JSON or YAML) are in the latter.

Re:Major mode for editing SEML (S-Expression Markup Language... by jakear on Monday June 03, 2019 @01:05AM (#20080528)
Skimmed the article, left me a bit confused. Am I missing something big, or is this not particularly novel? The similarities between a-expressions and XML seem fairly obvious to me.
Re:Major mode for editing SEML (S-Expression Markup Language... by neilv on Monday June 03, 2019 @05:20AM (#20081568)
It's obvious to any Lisp person, and very convenient, in some wasys.

A few things usually going on with S-expression representation of XML or HTML encoding in a Lisp:

1. It uses some of the native basic types of Lisp -- the list, the symbol, and the string.

2. The HTML element values that you type in your source and that are displayed to you are generally in the same syntax, since that's how Lisps tend to work with the basic types. (For contrast, you don't type your HTML like `<html><body><p>Hi</p></body></html>` in your source, and then see it in the debugger like `HtmlElement#abcd1234("html", {HtmlElement#c948f447("body", {HtmlElement#e7e7e7e7("p", {HtmlCdata#c8c8c8c8c8("Hi")})})})`.

3. The S-expression printed representation you see in your source can be less verbose than HTML or XML, such as by not needing HTML element end tags. Though you will have to put your HTML CDATA text as quoted string literals.

4. A Lisp person's typical code indenting (supported by the editor), tends to expose the tree/forest structure of HTML conveniently:

    (html (head (title "My Page"))
          (body (p "First paragraph.")
                (blockquote "Don't quote me on that.")
                (div (p "Another paragraph.")
                     (p "Yet another paragraph."))
                (p "Hey, it's a paragraph.")))
Note that I probably wouldn't type a huge book this way. I might instead use Markdown or a DSL or alternate reader, such as Scribble or its at-reader, mainly to get TeX-like paragraphs: https://docs.racket-lang.org/scribble/ https://docs.racket-lang.org/scribble/reader-internals.html
Re:Major mode for editing SEML (S-Expression Markup Language... by tannhaeuser on Monday June 03, 2019 @07:45AM (#20082165)
> The S-expression printed representation you see in your source can be less verbose than HTML, such as by not needing HTML element end tags

Tag inference/omission in SGML (and by extension HTML when seen as an application of SGML) is way more powerful. A minimal, valid HTML document is this:

    <title>Whatever title</title>
    <p>Text goes here
SGML's tag inference, when coupled with a DTD for HTML5 such as mine [1], will treat that as equivalent to this:

    <html>
      <head>
        <title>Whatever title</title>
      </head>
      <body>
        <p>Text goes here</p>
      </body>
    </html>
See details in slides or paper linked from [2].

[1]: http://sgmljs.net/docs/w3c-html51-dtd.html

[2]: http://sgmljs.net/blog/blog1701.html

Re:Major mode for editing SEML (S-Expression Markup Language... by neilv on Monday June 03, 2019 @08:06AM (#20082272)
Neat that you've done this for HTML5. Early Web browsers tended to do some of that (with less-rigorous semantics, some of which I approximated in my early HTML parser). Consequently, Web pages in practice often did, too. Maybe that could make manual writing of documents in HTML5 more practical. For bits of HTML embedded in code lately, I've preferred a simpler model and syntax using S-expressions, but I could see the implied tags as very useful for handwriting documents SGML-style.
Re:Major mode for editing SEML (S-Expression Markup Language... by txru on Monday June 03, 2019 @01:33AM (#20080631)
Well, it is and isn't novel. S-expressions have been around since McCarthy, XML since the mid-90's. The point of the article is that XML is a more verbose re-interpretation of s-expressions-- it's hard to find things that XML brings to the table that sexps don't have. What's more, inside editors, there are really clever things that manipulate sexprs, move them around, redefine their semantic meaning. XML usually doesn't work quite that way, not as a first intent.
Re:Major mode for editing SEML (S-Expression Markup Language... by tannhaeuser on Monday June 03, 2019 @02:12AM (#20080780)
SGML has been around since the 1960s, and XML is specified as a proper subset of it. SGML/XML isn't so much about (trivial) nesting than it is about content models, eg. the language defined by a regular expression admitted/recognized as the content of a particular element. Markup is also first and foremost a plain text format, optionally tagged by start-/end-element tags, unlike sexprs which need quotes around individual spans of text. Try telling an author to use verbose quoting (and escaping for quotes) for what makes the majority of his text format, or try edititing a large text with verbose sexpr yourself, and you'll see why nobody uses sexprs for semistructured text.
Re:Major mode for editing SEML (S-Expression Markup Language... by txru on Monday June 03, 2019 @02:54AM (#20080974)
I take your point, and I really don't want to be the spark of a syntactic flamewar. I suspected I was missing something, and that the $angle_bracketed_format was older, but I was searching the wrong things.

It seems to me, though, that escaping is just something that's going to be tricky everywhere, and a decent first line solution, wherever you are, is to have a really rare set of characters represent your begin/end string marks. In Python, """text""", Postgres has $$text$$, non-ASCII characters in other formats. XML and sexps are both susceptible to that issue-- both of their escapes are, themselves, escapable. To either one, if you have a subregion that's likely to be unintentionally escaped, then you create a boundary where you either explicitly escape every one, or you refuse to acknowledge previously accepted delimiters. As an example, lisps have (quote term) rather than 'term when you're writing macros and concerned with macro-expansion.

To your regex point, there are lisps that definitely did awful deeds with that, particularly emacs lisp, but the more recent ones have solutions just like other modern programming languages and markups do.

To me the unending escape just kind of seems like a universal bug. While lisp is just as susceptible, lisps have perfectly reasonable ways of treating these problems-- separate, make distinct, and as last resort, escape.

Re:Major mode for editing SEML (S-Expression Markup Language... by goto11 on Monday June 03, 2019 @04:14AM (#20081307)
SGML came out of document authoring and publishing. SGML is more suited for this domain because (among other things) you don't have to quote every single string. It is not like the SGML community didn't know about s-expressions - DSSSL the style language for SGML was based on scheme, so they recognized s-expressions were appropriate for some domains.