Hot questions for Using Cap'n Proto in json
Please help to suggest some merits and demerits of Flatbuffers and CBOR protocols. Both these binary formats claim to be good on their websites, but I am not able to make some good differences between the two.
- Strict typing in FlatBuffer, Cap’n proto and other similar solutions is seen as major key point for performance since no additional encoding/decoding is necessary.
- The data model allows simple offsetting of typed objects with a compact data structure and fast access
- FlatBuffers does not need a parsing/ unpacking step to a secondary representation before you can access data often coupled with per-object memory allocation.
- New and not standardized like CBOR.
- Can create and process entirely in stream with no extra memory
- Don’t have to pre-define any schema as our data is dynamic and variant
- It’s an open international standard from the IETF makes it a even better choice than a proprietary one.
- It’s designed for low memory, non-conversion, stream-based processing while also providing extensions for other data types
- CBOR says that it follows the JSON model (so not strictly typed objects)
- It starts with the same types of objects (strings, integers, maps, etc.).
PS: It feels like managing types in CBOR will be performance costly compared to flatbuffers, but as CBOR is standardized protocol I am inclined to prefer it if this difference is not huge. Please let me know which of two will you all recommend and why.
I think you've already spelled it out quite clearly yourself. FlatBuffer's strength is being able to access the data without parsing/unpacking/allocation, which can give serious performance benefits in some scenarios. But if this doesn't matter to you, e.g. Protocol Buffers may work just as well.
Strong typing vs dynamic typing in data matters a lot too. I'd only use the latter if I wanted generic data storage with no constraints ahead of time.
Btw, if for some reason you prefer dynamic typing, but would also like to have the performance benefits of in-place access, there is actually a format that combines the two: https://google.github.io/flatbuffers/flexbuffers.html
FlatBuffers is not "proprietary". It may have been designed at Google, but it is open source and relied upon by many other companies.