Live data from Hacker News

Thoughts on Canonical S-Expressions (2019)

write.emacsen.net

1–10 of 15 posts

Re: Thoughts on Canonical S-Expressions (2019)

#4
We changed the url from https://en.wikipedia.org/wiki/Canonical_S-expressions to a non-Wikipedia article. (Wikipedia submissions are fine but if there's a good third-party source, those are usually preferred because they're less generic.)

Readers may want to look at both of course!

Re: Thoughts on Canonical S-Expressions (2019)

#5
Canonical S-expressions seem remarkably similar to bencoding as used in BitTorrent files. They both use length prefixes written in ASCII digits followed by a colon.

    Canonical S-Expression: (9:groceries(4:milk5:bread))
    Bencoding:              l9:groceriesl4:milk5:breadee
Bencoding also manages to specify dictionaries, and yet still have a canonical encoding, by requiring dictionaries be sorted by key (and keys be unique).

It doesn't have the option for arbitrary type names, it just has actual types: integer, bytestring, list and dictionary.

FTA:

> Bencoding offers many of the same benefits of CSEXP, but because it also supports types, is a bit easier to work with.

Hmm, well there you go.

Re: Thoughts on Canonical S-Expressions (2019)

#6
post #3

Imagine if we had this instead of shitty ass C or asm lol

Canonical S-Expressions aren't meant to replace something like C or assembly, they're for data serialization. It's meant to be compared against things like JSON, XML, ASN.1, or any other serialization format.

Re: Thoughts on Canonical S-Expressions (2019)

#7
post #5

Canonical S-expressions seem remarkably similar to bencoding as used in BitTorrent files. They both use length prefixes written in ASCII digits followed by a colon. Canonical S-Expression: (9:groceries(4:milk5:bread)) Bencoding: l9:groceriesl4:milk5:breadee Bencoding also manages to specify dictionaries, and yet still have a canonical encoding, by requiring dictionaries be sorted by key (and keys be unique). It doesn…

[deleted]

Re: Thoughts on Canonical S-Expressions (2019)

#8
I would suggest the author also look at Amazon Ion:

* It can be used as schema-less

* allows attaching metadata tags to values (which can serve as type hints[1]), and

* encodes blobs efficiently

I have not used it, but in the space of flexible formats it appears to have other interesting properties. For instance it can encode a symbol table making symbols really compact in the rest of the message. Symbol tables can be shared out of band.

[1] https://amazon-ion.github.io/ion-docs/docs/spec.html#annot

Re: Thoughts on Canonical S-Expressions (2019)

#9
post #4

We changed the url from https://en.wikipedia.org/wiki/Canonical_S-expressions to a non-Wikipedia article. (Wikipedia submissions are fine but if there's a good third-party source, those are usually preferred because they're less generic.) Readers may want to look at both of course!

Thanks for the plug on this very old article/topic.
Post reply on HN