Live data from Hacker News

Protocol Buffers v3.0.0 released

github.com

41–50 of 131 posts

Re: Protocol Buffers v3.0.0 released

#41
post #36

Earlier quoted context omitted.

> removing optional values Slight correction: optional values are not removed. Quite the opposite; the "optional" keyword is removed because now all fields are optional. It is actually required values which were removed.

True. But when using them, it feels like every field is "present" and you don't have to worry about the "optional, missing" case.

For primitives, yes, but not messages.

Re: Protocol Buffers v3.0.0 released

#43

In C# why use Protocol Buffer over the XML or binary serializes?

The C# binary serializer is not really comparable in terms of what it does. It's more like Python's Pickle library.

http://stackoverflow.com/questions/703073/what-are-the-defic...

C# binary serialization is only useful in certain circumstances. It doesn't work outside the .NET world and it even has compatibility problems within the .NET world—you can break deserialization by making certain changes to your code. From the Microsoft documentation:

> The state of a UTF-8 or UTF-7 encoded object is not preserved if the object is serialized and deserialized using different .NET Framework versions.

(From https://msdn.microsoft.com/en-us/library/72hyey7b(v=vs.110)....)

Also see https://msdn.microsoft.com/en-us/library/ms229752(v=vs.110)....

Re: Protocol Buffers v3.0.0 released

#45
They added a feature that impressively fails to interoperate with the rest of the world.

> Added well-known type protos (any.proto, empty.proto, timestamp.proto, duration.proto, etc.). Users can import and use these protos just like regular proto files. Additional runtime support are available for each language.

From timestamp.proto:

  // A Timestamp represents a point in time independent of any time zone
  // or calendar, represented as seconds and fractions of seconds at
  // nanosecond resolution in UTC Epoch time. It is encoded using the
  // Proleptic Gregorian Calendar which extends the Gregorian calendar
  // backwards to year one. It is encoded assuming all minutes are 60
  // seconds long, i.e. leap seconds are "smeared" so that no leap second
  // table is needed for interpretation.
Nice, sort of -- all UTC times are representable. But you can't display the time in normal human-readable form without a leap-second table, and even their sample code is wrong is almost all cases:

  //     struct timeval tv;
  //     gettimeofday(&tv, NULL);
  //
  //     Timestamp timestamp;
  //     timestamp.set_seconds(tv.tv_sec);
  //     timestamp.set_nanos(tv.tv_usec * 1000);
That's only right if you run your computer in Google time. And, damn it, Google time leaked out into public NTP the last time their was a leap second, breaking all kinds of things.

Sticking one's head in the sand and pretending there are no leap seconds is one thing, but designing a protocol that breaks interoperability with people who don't bury their heads in the sand is another thing entirely.

Edit: fixed formatting

Re: Protocol Buffers v3.0.0 released

#46
post #24

Earlier quoted context omitted.

Yes, I read this. It tells me what Protocol Buffers are. Faster, Smaller XML like data structures for serialisation. What are the most common use cases though? And do people only use them for performance reasons?

As an example, they power Google's RPC system (usually referred to as Stubby in the literature, recently open sourced as gRPC http://www.grpc.io/ )

gRPC is based on Stubby: http://www.grpc.io/posts/principles

Re: Protocol Buffers v3.0.0 released

#47

Google also has flatbuffers. I wonder if flatbuffers is being used by enough developers to justify significant development? https://github.com/google/flatbuffers

Been using flatbuffers in production for a high speed market feed for a month now. Love it. Decode/encode time is absurdly fast (~1-2 microseconds for a small to medium schema). If you're pushing 50k+ events/second it can be a great choice. Takes up almost no space on the wire too.

Try Cap'n Proto instead. Better designed and faster.

Re: Protocol Buffers v3.0.0 released

#48

Sadly the JSON format they chose isn't actually suitable for high-performance web apps. Web developers who use protobufs will continue to get by with various nonstandard JSON encodings.

Why isn't is suitable? (I've never used protobufs)

The fields are indexed by field names (converted to lower camel case) instead of tag numbers. It's great for readability, but it's a lot more verbose, particularly for repeated fields.

Re: Protocol Buffers v3.0.0 released

#49

Sadly the JSON format they chose isn't actually suitable for high-performance web apps. Web developers who use protobufs will continue to get by with various nonstandard JSON encodings.

Why would you use JSON in a high performance context anyway?

Because the code is running in a browser.

Browsers do support binary data using typed arrays but for some reason this isn't commonly used yet. Compatibility, maybe?

Re: Protocol Buffers v3.0.0 released

#50
post #45

They added a feature that impressively fails to interoperate with the rest of the world. > Added well-known type protos (any.proto, empty.proto, timestamp.proto, duration.proto, etc.). Users can import and use these protos just like regular proto files. Additional runtime support are available for each language. From timestamp.proto: // A Timestamp represents a point in time independent of any time zone // or calenda…

> designing a protocol

It's not a full protocol. It's a data type for a serialization library. You can write your own data types and they serialize just as well as the built-in types.

> that breaks interoperability

Wait, what was "broken" here? What was working before that isn't with this new release? What does this inclusion of a utility data type in a serialization library break that previously was intact?

Post reply on HN