6 ms·
You absolutely can. You can also use Square’s excellent Wire library.
by joe_fishfish 3y ago
You absolutely can. You can also use Square’s excellent Wire library.
- MarkMarine 3y agoYou can but you’re going to have ? EVERYWHERE, which does drive the search for a native implementation that doesn’t make you deal with null everywhere
- billjings 3y agoIs there another way you're supposed to represent optionals in Kotlin?
- MarkMarine 3y agoNo, but it makes the code a mess because you’re handling optionals for every protobuf field deref. So you’ve got error handling all over the place. It looks like go’s error handling.
- skybrian 3y agoThey really are optional though. This is inherent in the problem if you want to support arbitrary past and future versions. You need to decide what to do when the data is missing. Open file formats are a difficult problem. [1] I might define a different class for a validated object, so version skew only needs to be dealt with at the system edge. Maybe you don’t actually have that problem because you can make a closed-world assumption? For example, you control all writers and aren’t saving any old-format data, like in a database that has a schema. In that case you can make fields required. [1] https://acko.net/blog/on-variance-and-extensibility/ https://acko.net/blog/on-variance-and-extensibility/