The Proto2 and Proto3 syntaxes are quite similar, but have some distinct differences. To begin this comparison, I’m going to highlight some of the features of Proto2 that are not present in Proto3. These features include, but are not limited to:
- Required message fields. This can be useful for things like SOW keys.
- Ability to set custom default values for a field.
- Ability to determine if a missing field was not included, or was assigned the default value. This is needed for AMPS to use delta messaging.
- Support for nested groups.
The Proto3 syntax contains the addition of many new features that were not present in the Proto2 syntax, as well as the removal of some existing features. These changes include:
- Removal of required fields.
- Removal of default values. Primitive fields set to a default value are not serialized.
- Addition of JSON encoding instead of binary protobuf encoding.
- Extensions have been replaced by the Any type.
- Addition of well-known type protos. These include any.proto, timestamp.proto, duration.proto, etc.
- Strict UTF-8 checking is enforced.