by dayjah · 10y ago · 0 comments
[1] https://developers.google.com/protocol-buffers/docs/encoding
Protobufs depend, for interpretability, on a schema. That is, if you don't have the schema file (which is normally communicated out-of-band, e.g. by source control), you know almost nothing about what the wire-encoding should decode to.
Protobufs use variable-length integers (varints), both as a datatype for the payload, and as an essential feature in understanding the encoding.
The wire keys in protobufs don't fully specify the datatype. Instead they include 3 bits to tell you what length-scheme is used, and some other bits (variable number of bits, because varint) to tell you which field in the schema will tell you the rest of the datatype for this field (as well as the key-name of the field).
Protobuf is a rich protocol for doing potentially-complicated things. This OSC thing is very nearly the dumbest thing that could work. Indeed, Armstrong's post makes a point of noting that. To him, that's a feature.
A leading thought in a lot of this is the "unset and a zero value are equivalent". It simplifies a lot of what the serializer and deserializers have to understand, and places the burden on code generation or libraries rather than complex serialization. It was unnatural for me to think this way, as I take the opposite for memory (record whether something is set or not, don't just assume it equals zero), but on the wire this makes for very compact and backwards compatible messaging.
Cap'n Proto[1] I have not played with, but would love to learn more about to see the advantages and disadvantages between protobuf, msgpack, and capn.
[0]: http://msgpack.org/
Message Pack has a specification that is well documented[0] and even the rfc you refer to specifically states it has different goals (though, eliding specifics with pretty sad generalizations)[1]
You find those generalizations sad because that is the acknowledgements section!
If you start from the beginning, you only need to read three paragraphs to see that "Appendix E lists some existing binary formats and discusses how well they do or do not fit the design objectives of the Concise Binary Object Representation (CBOR)." [0]
If we look at Appendix E, [1] we find that section E.2 contains an explanation that you're likely to be more satisfied with. [2] However, before you go off and read section E.2, I strongly urge you to read the couple of paragraphs in Appendix E, first. The authors of RFCs generally tend to try hard to remove redundancy in their prose, and later sections often elide information covered in earlier sections.
[0] https://tools.ietf.org/html/rfc7049#section-1