Protobuf advantages
ProtoBuf Advantages:
1, good performance/high efficiency
Time overhead: XML formatting (serialization) overhead is fine; But the overhead of XML parsing (deserialization) is less than flattering. But ProtoBuf is optimized for this. You can reduce the time overhead of both serialization and deserialization.
Space overhead: also reduced a lot
2. There are code generation mechanisms
Let’s say you write something that looks like a structure
message testA
{
required int32 m_testA = 1;
}
As with writing a structure like this, ProtoBuf can automatically generate its.h file and dot-cpp file. ProtoBuf encapsulates operations on the structure testA as a class.
3, Support backward compatibility and forward compatibility
When the client and server colleagues use a block protocol, when the client adds a byte to the protocol, it does not affect the client’s usage
4. Support multiple programming languages
In Google’s official release of the source code contains C ++, Java, Python three languages
Protobuf shortcomings
1. Binary format leads to poor readability
To improve performance, ProtoBuf is encoded in a binary format. This leads directly to poor readability. This directly affects the efficiency of development testing. Of course, in general, ProtoBuf is very reliable and shouldn’t be a big problem.
2. Lack of self-description
In general, XML is self-describing, while the ProtoBuf format is not. Given a piece of protocol content in binary format, it won’t work if it doesn’t match the structure you wrote.
3. Poor versatility
ProtoBuf does support serialization and deserialization for a number of languages, but it is still not a cross-platform or language transport standard. In multi-platform messaging, the compatibility of other projects is not very good, so it needs to be adapted accordingly. Compared to JSON and XML, the versatility is still not as good.