Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Protocol Buffers and Flatbuffers?

People also ask

What are protocol buffers?

Protocol buffers are a combination of the definition language (created in . proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).

Should I use protocol buffers?

We recommend you use Protobuf when: You need fast serialisation/deserialisation. Type safety is important. Schema adherence is required.

What is protocol buffers gRPC?

Protocol Buffer, a.k.a. Protobuf Protobuf is the most commonly used IDL (Interface Definition Language) for gRPC. It's where you basically store your data and function contracts in the form of a proto file.

Why is it called protocol buffer?

Why the name "Protocol Buffers"? The name originates from the early days of the format, before we had the protocol buffer compiler to generate classes for us. At the time, there was a class called ProtocolBuffer which actually acted as a buffer for an individual method.


I wrote a detailed comparison of a few serialization systems, including Protobufs and FlatBuffers, here:

https://kentonv.github.io/capnproto/news/2014-06-17-capnproto-flatbuffers-sbe.html

However, the comparison focuses more on comparing the three new "zero-copy" serialization systems, and includes Protobufs mostly as a reference point. Also, I'm the author of Cap'n Proto, and also the author of Protobufs v2 (I was responsible for open sourcing Protobufs at Google), so the comparison may be biased.

(Updated in 2021:) Note that Protobufs was introduced at Google way back in 2001 or so and remains the "lingua franca" there today. FlatBuffers was introduced in 2014 and is used in some projects, but Protobuf remains Google's main data interchange format, and there is no intention to change that. To be fair, Google probably couldn't change this if they wanted to, there's just too much code.