Remaining differences between proto2 and proto3

3,693 views
Skip to first unread message

zel...@gmail.com

unread,
Mar 26, 2021, 9:34:26 AM3/26/21
to Protocol Buffers
Hi folks.

I just noticed that proto3 got optional fields. At my workplace, Square, we've been stuck on proto2 forever, because we have a mountain of protos that both optional fields and proto option annotations all over the place.

Is there an up-to-date summary of the remaining differences between proto2 and proto3? If proto3 is converging on full proto2 functionality support, there's a chance we could migrate to proto3, which would be extremely helpful: proto3 seems better supported in Ruby, for example.

Thanks,

Zellyn Hunter

David Gomez

unread,
Mar 26, 2021, 10:08:42 AM3/26/21
to zel...@gmail.com, Protocol Buffers
I work at Google and I can tell you that proto2 and proto3 freely interoperate. That is, they can reference symbols across versions and generate code that works well together. It is entirely reasonable for a proto2 message to reference a proto3 enum or message, and vice versa, with the exception that proto3 messages cannot reference proto2 enums due to differences in semantics.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/45733f56-a82b-4f1e-84bc-71d55e7ef78bn%40googlegroups.com.

Derek Perez

unread,
Mar 26, 2021, 11:47:22 AM3/26/21
to David Gomez, zel...@gmail.com, Protocol Buffers
There should be no reason you can't use proto3 along with proto2 just fine. The underlying serialization is compatible, one major difference if you care about encoding options is that proto3 has packed fields on by default for repeated, but this can also be manually enabled for repeated fields in proto2.

Also, proto2 has extensions whereas proto3 does not. There should be no interop issues. I am less familiar with this enum incompatibility issue, that seems odd to me since I imagine this if anything would be target language related and not inherently a proto2 to proto3 limitation. There's some rules about what the zeroth item must be, but that's all I can think of: https://developers.google.com/protocol-buffers/docs/proto3#enum



Reply all
Reply to author
Forward
0 new messages