back

by dochtman·5y ago·view on hn ↗
I liked this CBOR vs MsgPack article from a while back (which also talks about size on the wire, not just performance):

https://diziet.dreamwidth.org/6568.html

SBE (Simple Binary Encoding) also makes some interesting performance claims.

My pet peeve with both protobuf and capnp is the lack of an option type; they seem to be designed for languages with type systems that include null, rather than more modern languages like Rust or Kotlin.

3 comments
Another vote for CBOR. I had actually designed my own binary JSON encoding out of frustration with BSON (which nobody should use IMO). My format was focused on compactness, but I dropped it when I found CBOR which was very similar and even slightly better in places. One notably thing about CBOR is the support for both Indefinite and Definite-Length Arrays and Maps (typically streaming generators need the former whereas parsing the latter can be more efficient).
Interestng read, didn't know most of this. Not that it matters in the end: at one point we just needed something simple which would just work and MessagePack does just that :)

Btw JSON is often a popular choice, but although this is not explicitly mentioned in the main article as a con which is an oversight imo, the actual JSON standard does not support NaN/+-Inf for floating point. That's insane, which is why most implementations have an option to allow that anyway, but not all, which can be quite the showstopper.

Protobuf has fields that may not be required (although it is advised not to use it). How is that different from Option?