Re: Binary S-expressions Lassi Kortela 17 Sep 2019 09:46 UTC

John:
> IMO this does not really save anything much over a textual protocol given
> that the servient (server-client) is running (normally) on the same machine
> as the original client.  The pipes are fat.

It's not about performance, it's about simplicity and reliability.

- A format where every object is length-prefixed makes memory allocation
in C much easier: just call malloc() with the right size off the bat and
one read() can fill in the buffer.

- No lookahead is needed so parsers in other languages are also easier.
It generally makes no sense to have lookahead in formats for machines.

- Length-prefixes also obviate the need to escape strings and symbols
escaping, which I would consider mandatory for almost any format meant
for machines.

- Arbitrary binary data is trivial to embed in exactly the same way as
text strings.

I always start from a binary protocol, and ask whether a textual one
saves anything. It's so much easier to avoid all the pitfalls.