2 ms·
Protobufs don't follow this model. For example, a User message type will often be defined in one place and code generated from it in multiple languages. Every s
by skybrian 7y ago
Protobufs don't follow this model. For example, a User message type will often be defined in one place and code generated from it in multiple languages. Every server and client uses essentially the same type, modified as suitable for that language. As a result, clients are usually working with types that they don't control and that have many more fields than they actually use.
Maybe clients should declare their own types containing just what they need and copy the data into them from the protobufs? But this does get tedious. On the other hand, in a schemaless JSON system, there is nothing statically checking that the clients and servers have compatible ideas of what a message should contain.
- msangi 7y agoWith protobufs you get bytes that you have to parse with defined rules on what to do with unexpected and missing fields. How’s it different from the proposed model where you start by parsing the data you receive and, once it’s parsed and know it’s good, you process it?
- skybrian 7y agoIt probably would work, provided that each client takes the original proto file and removes all the fields they don't use, so they are treated as unknown fields? I don't know if there's a supported way to do this, though. To leverage it for refactoring, there would also need to be a way to do a query to find out out which clients use which fields.