问题描述
Protobuf的卖点之一是向后兼容,即开发人员可以发展格式,而老客户仍然可以使用它.
One of selling points of Protobuf was backward compatibility, i.e. developers can evolve format, and older clients can still use it.
现在有了新的Protobuf版本proto3,IDL语言本身不兼容诸如options
,required
放在其中,新的enuns语法,无扩展性之类的东西.
Now with new Protobuf version called proto3, the IDL language itself is not compatible as such things as options
, required
where dropped, new syntax for enuns, no extention.
这是否意味着使用proto3无法产生较旧的proto2也会读取/理解的二进制文件?
Does it mean that using proto3 there's no way to produce binary that older proto2 would read/understand also?
这就像您必须继续使用proto2.如果您开始使用proto3,则无法与较旧的系统通信,或者必须重写,重新编译所有这些.proto
首先是兼容性中断.
It is like you have to continue to use proto2. If you start using proto3, you can't talk to older systems, or have to rewrite, recompile all those .proto
sThat is compatibility break in the first place.
推荐答案
是的,如果您的某些系统基于proto2,则最好继续使用proto2.我认为proto3没有引入许多新功能,并且大多数库将继续支持proto2.
Yes, if some of your systems are proto2 based, it is probably best to keep using proto2. In my opinion, proto3 does not introduce many new features and most libraries will continue supporting proto2.
但是,wire格式几乎是兼容的.只要标签号相同,编码就保持相同.必需/可选说明符不影响编码,它们只是在解码后执行的检查.
However, the wire format is mostly compatible. As long as the tag number is the same, the encoding remains the same. The required/optional specifiers do not affect the encoding, they are only checks that are performed after decoding.
这篇关于Protobuf向后兼容性以及Proto3与Proto2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!