Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The other alternative is what protobuf did to solve the same pain: In proto3, all optionals have a default value. They're effectively required where the default value doesn't need to be encoded in the message.

The exact different between the two approaches is subtle. Technically you can fancier things with the framework exposing the optional values as set/not set, but in practice a lot of code is a lot simpler with default values.

https://protobuf.dev/programming-guides/proto3/#default



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: