The syntax 3 of protobuf made all the fields optional dropping the keywords required
and optional
from previous proto2 syntax. Reading some comments from developers it seems that it was done for enhancing forward/backward binary compatibility.
But for me, that could be enforced by just versioning the package names, say com.example.messages.v1
and then let clients to implement deserializers they understand. At the same time it removes some contracts stated as a type that are useful from a software engineering point of view. For instance if I have
message Location {
double latitude = 1;
double longitude = 2;
}
In proto3 it is possible to create a half backed but perfectly valid Location
by not providing one of the required fields.
Isn't that a big drawback when creating a schema based serialization format for exchanging data between clients? Isn't worse to move extra validation code to each client checking that all required fields have valid values?