3 ms·
That looks surprisingly like bencode used by BitTorrent.
by koolba 3y ago
That looks surprisingly like bencode used by BitTorrent.
- neilv 3y agoThat was my first thought (maybe because I was thinking about Racket, and happened to hack up a quick bencode parser in Scheme, https://www.neilvandyke.org/racket/bencode/ https://www.neilvandyke.org/racket/bencode/ ), but it's not just bencode. I think a lot of data encoding protocols that are for arbitrary non-app-specific data needing more structure than Unix shell tools lines&whitespace, and intended to be simple, but you still want to make them efficient to parse while streaming, end up like this. You have a few types, some values are variable length, historically you often choose ASCII character set (for human readability, portability to different platforms, passability of different gateways), and you might as well minimize parsing lookahead, so there's some likely ways you'll signal types and sizes in the stream. Google Protobufs (for another contemporary popular protocol) has somewhat different requirements, which leads to less-text result. But if you had those requirements (say, extensible types like in a traditional rich RPC mechanism, and maybe minimizing bandwidth), you might end up doing much the same thing. Or, today, you and GPT-4 might just punt on "micro-optimizations", and layer atop JSON or maybe still XML.