Re:The Protobuf Language Specification
by joshuamorton on Tuesday September 13, 2022 @03:07AM
(#32821447)
This is true for proto3, but not for proto2 (except for repeated fields, which are always non-null but can contain 0 items).
Proto2 has `HasFoo` methods, which distinguish between empty (unset/null) and set explicitly to zero fields.
I don't like that proto3 made this choice, I think it was wrong, but there was some rationale behind it beyond just "elegance".
Re:The Protobuf Language Specification
by somenameforme on Tuesday September 13, 2022 @03:21AM
(#32821519)
Can you elaborate on the reasons for the decision? I've always been quite curious on the reasoning there.
2) Serialization for storage or transit
Unless the spec has changed, there's a fun issue. In protobuf there's no notion of null. So for instance a null list and an empty list are serialized identically. This leads to a nightmare in any system where null can have meaning by itself. I was always confused by this decision since there would be an endless number of ways to represent null that would have near zero impact on size or performance. The only cost I can see is the abstract one of making the representation less "elegant."
There are a of course endless ways to overcome this issue, but I don't think serialization implementation details should ever be allowed to leak into the model of what's being serialized. Just begging for issues down the road.