6

I was wondering if protocol buffer's serialized data format remains constant across protobuf compiler and client library versions.

In other words, do I need to use the same compiler version to generate my Python, Java, and C++ classes? And do these clients all need to use the same version of protobuf libraries?

This post sort of addresses my question, but its accepted answer is specific to the OP's protobuf version.

Community
  • 1
  • 1
pepsi
  • 6,785
  • 6
  • 42
  • 74

1 Answers1

3

Yes, that is pretty much the idea. It shouldn't matter which library you use, as long as it follows the spec. Note that the same data can be represented in slightly different ways, for example field order should not matter to the client, and while it is common for clients to write fields in ascending order, it is explicitly required of clients to process fields in any order. All I'm saying here is that it might not be exactly the same bytes in the same order, but it should work fine from any client.

Note that some implementations might offer additional features (*cough* like mine offers inheritance support), intended for use primarily only within that single client. In that case, I would a: expect those features to be obvious when used, and b: it should always still produce a valid protobuf stream (you might just choose to ignore those fields, or support them as bytes for the purpose of round-trip).

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • if its not "exactly the same bytes in the same order", many clients will break. anyone that relies on hashing and crypto signatures. – jaybny Aug 24 '15 at 15:59