Recently (January 2015) Microsoft open-sourced Bond, their framework for working with schematized data. In many aspects it is similar to Google's Protocol Buffers.
What are the biggest differences between the two? What are pros and cons, that is, in which situations I would like to use one, but not the other? Of course, I'm not talking about obvious things like consistency with other projects or already existing APIs, but rather the features of both libraries. To give an example, Bond has bonded<T>
which, if I remember correctly, doesn't have a counterpart in Protocol Buffers.
Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.
Protobuf is a binary data-interchange format developed by Google, whereas JSON is the human-readable data-interchange format. JSON is derived from JavaScript but as the name suggests, it is not limited to JavaScript only. It was designed in such a way that it can be used in multiple languages.
Protocol buffers provide a language-neutral, platform-neutral, extensible mechanism for serializing structured data in a forward-compatible and backward-compatible way. It's like JSON, except it's smaller and faster, and it generates native language bindings.
Microsoft Bond is a modern data serialization framework. It provides powerful DSL and flexible protocols, code generators for C++ and C#, efficient protocol implementations for Windows, Linux, and Mac OS X.
In general, Bond has better type system and supports multiple protocols.
In particular, pros are:
vector<T>
, map<T>
, list<T>
bonded<T>
)Cons:
fixed32
and fixed64
.oneof
in Protocol Buffers)I did some tests, and it appears that size of simple messages in Bond and ProtoBuf binary formats are about the same. I compared serialization and deserialization time using Bond and C# ProtoBuf library: in my case Bond performed a bit better, you can find my source code on GitHub
To sum up, I think it's better to use Bond when you work with some complex types of data or when you need to represent the same data in different formats: e.g. store as binaries, but expose as JSON etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With