(to be clear: I'm just a lurker here - this is just an opinion, not an official answer of any kind)
IMO that's absolutely fine; it isn't even necessarily any larger; in many cases it'll be exactly the same size - it'll only be larger when fields are *explicitly* assigned zero/false/etc, and the delta is minimal (commonly +2 bytes per such value, depending on the field number) Marc On Fri, 24 Jan 2025 at 16:07, 'Jeppe Fihl-Pearson' via Protocol Buffers < [email protected]> wrote: > Hi > > Is there any big downside to marking all fields optional in proto3 besides > the slightly larger resulting wire format? > In our case, we will use Protobuf/gRPC for server-to-server communication, > where a bit of network overhead doesn't matter. > > Knowing whether a field has been populated seems like a nice benefit of > marking fields optional, and it also appears to be the default for the > "2023 edition” version. > > I'm wondering if marking all fields as optional would be considered an > anti-pattern and if this shouldn't be necessary if the messages are better > structured. > > Thanks > Jeppe > > -- > 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 [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/protobuf/c012cb4e-1057-4c79-9ca4-3454afd1e3ffn%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/c012cb4e-1057-4c79-9ca4-3454afd1e3ffn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Regards, Marc -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/protobuf/CAF95VAye%2BMW2tY2rALOLHbTwJECqVta5naKJLjEFHdmtNx0_fQ%40mail.gmail.com.
