TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Protocol Buffers v3.0.0 released

278 pointsby Rican7almost 9 years ago

14 comments

amlutoalmost 9 years ago
They added a feature that impressively fails to interoperate with the rest of the world.<p>&gt; 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.<p>From timestamp.proto:<p><pre><code> &#x2F;&#x2F; A Timestamp represents a point in time independent of any time zone &#x2F;&#x2F; or calendar, represented as seconds and fractions of seconds at &#x2F;&#x2F; nanosecond resolution in UTC Epoch time. It is encoded using the &#x2F;&#x2F; Proleptic Gregorian Calendar which extends the Gregorian calendar &#x2F;&#x2F; backwards to year one. It is encoded assuming all minutes are 60 &#x2F;&#x2F; seconds long, i.e. leap seconds are &quot;smeared&quot; so that no leap second &#x2F;&#x2F; table is needed for interpretation. </code></pre> Nice, sort of -- all UTC times are representable. But you can&#x27;t <i>display</i> the time in normal human-readable form without a leap-second table, and even their sample code is wrong is almost all cases:<p><pre><code> &#x2F;&#x2F; struct timeval tv; &#x2F;&#x2F; gettimeofday(&amp;tv, NULL); &#x2F;&#x2F; &#x2F;&#x2F; Timestamp timestamp; &#x2F;&#x2F; timestamp.set_seconds(tv.tv_sec); &#x2F;&#x2F; timestamp.set_nanos(tv.tv_usec * 1000); </code></pre> That&#x27;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.<p>Sticking one&#x27;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 <i>don&#x27;t</i> bury their heads in the sand is another thing entirely.<p>Edit: fixed formatting
评论 #12187876 未加载
评论 #12188412 未加载
评论 #12189202 未加载
评论 #12188287 未加载
评论 #12190781 未加载
评论 #12190874 未加载
评论 #12188179 未加载
评论 #12189015 未加载
评论 #12188604 未加载
评论 #12187983 未加载
评论 #12187745 未加载
评论 #12189168 未加载
评论 #12187904 未加载
zellynalmost 9 years ago
- removing optional values is actually quite nice. In practice, I end up checking for &quot;missing or empty string&quot; anyway.<p>- the &quot;well-known types&quot; boxed primitive types essentially add optional values back in. And depending on your language bindings, may look the same.<p>- extensions are still allowed in proto3 syntax files, but only for options - since the descriptor is still proto2. It seems odd to build a proto3 that couldn&#x27;t represent descriptors.<p>- I still don&#x27;t understand the removal of unknown fields. Reserialization of unknown fields was always the <i>first</i> defining characteristic of protobufs I described to people. I actually read many of the design&#x2F;discussion docs internally when I worked at Google, and I still couldn&#x27;t figure this one out. Although it&#x27;s certainly simpler…<p>- Protobufs are the &quot;lifeblood&quot; (Rob Pike&#x27;s words) of Google: the protobuf team is working to get rid of significant Lovecraftian internal cruft, after which their ability to incorporate open source contributions should improve dramatically.
评论 #12187495 未加载
评论 #12187937 未加载
rdtscalmost 9 years ago
How does this compare or in general why would you pick this vs newer formats like Cap&#x27;n&#x27;proto or FlatBuffers?<p>From FlatBuffers overview I see this comparison:<p>---<p>Protocol Buffers is indeed relatively similar to FlatBuffers, with the primary difference being that FlatBuffers does not need a parsing&#x2F; unpacking step to a secondary representation before you can access data, often coupled with per-object memory allocation. The code is an order of magnitude bigger, too. Protocol Buffers has neither optional text import&#x2F;export nor schema language features like unions.<p>---<p>So are the newer ones useful mostly when serialization vs deserialization speed matters (<a href="https:&#x2F;&#x2F;google.github.io&#x2F;flatbuffers&#x2F;" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;flatbuffers&#x2F;</a>) ?
评论 #12188140 未加载
评论 #12192513 未加载
评论 #12188994 未加载
JoachimSchipperalmost 9 years ago
This looks like a nice evolution.<p>It&#x27;s a pity that the &quot;deterministic serialization&quot; gives so few guarantees; I have worked on at least one project that really needed this.<p>(Basically, we wanted to parse a signed blob, do some work, and pass the original data on without breaking the signature; unfortunately, this requires keeping the serialized form around, since the serialized form cannot be re-generated from its parsed format.)
评论 #12188422 未加载
评论 #12188259 未加载
jalfresialmost 9 years ago
&quot;The main intent of introducing proto3 is to clean up protobuf before pushing the language as the foundation of Google&#x27;s new API platform&quot;<p>Does anyone know if this means Google&#x27;s public APIs will be proto3 based? I quite like protobufs.
评论 #12187408 未加载
评论 #12187180 未加载
评论 #12187203 未加载
manish_gillalmost 9 years ago
If someone better informed than me can please explain - where and why would something like Protocol Buffers be useful?
评论 #12187488 未加载
评论 #12187355 未加载
评论 #12187291 未加载
评论 #12188084 未加载
评论 #12187328 未加载
评论 #12187359 未加载
评论 #12187431 未加载
评论 #12187542 未加载
评论 #12187758 未加载
评论 #12187274 未加载
gonyeaalmost 9 years ago
Shocking! Google&#x27;s started supporting more languages than just the ones they care about. I really hope this signals the death of their disdain culture.<p>Being a worthwhile Cloud provider means hiring experts in all sorts of languages and supporting their efforts.<p>Imagine a world where Google didnt just &quot;support node&quot; (YEARS late), but actually turned their v8 expertise into a Cloud product.<p>But that&#x27;d involve convincing Java-devs-turned-VPs to care about JavaScript, &lt;2004&gt;and EVERYONE knows that JavaScript is a terrible language.&lt;&#x2F;2004&gt;
skybrianalmost 9 years ago
Sadly the JSON format they chose isn&#x27;t actually suitable for high-performance web apps. Web developers who use protobufs will continue to get by with various nonstandard JSON encodings.
评论 #12187308 未加载
评论 #12187325 未加载
评论 #12187628 未加载
mattiemassalmost 9 years ago
Wow, this seems to address a bunch of problems I&#x27;ve experienced with protobuf in the past. Looks awesome!
评论 #12187120 未加载
forrestthewoodsalmost 9 years ago
Google also has flatbuffers. I wonder if flatbuffers is being used by enough developers to justify significant development?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers</a>
评论 #12187256 未加载
评论 #12187366 未加载
zbjornsonalmost 9 years ago
&gt; primitive fields set to default values (0 for numeric fields, empty for string&#x2F;bytes fields) will be skipped during serialization.<p>I don&#x27;t totally understand this. Presumably during deserialization they will be set to defaults and not missing? Otherwise, coupled with the removal of required fields, it seems impossible to actually send a 0-value number or empty string, or to send a proto without a field and not have it set to 0 or &quot;&quot; (have to explicitly null the field?).
评论 #12187253 未加载
bltalmost 9 years ago
I was hoping for packed serialization of non-primitive types. I once used Protobuf to serialize small point clouds, and ended up needing to serialize them as a packed double array and reconstruct the (x, y, z) structure at read time to avoid Protobuf malloc&#x27;ing each point individually. Not a huge deal, but it would be a real pain for more complex types.
andrewmcwattersalmost 9 years ago
Could someone explain to me why you would use Protocol Buffers, Cap&#x27;n Proto, etc versus rolling your own type-length-value protocol besides API interop?<p>What if your team could write a smaller TLV protocol, and it was necessary to keep your codebase small? Would this not be wise? Are Protobufs and party not comparable to TLV protocols?
评论 #12189064 未加载
评论 #12189019 未加载
wehadfunalmost 9 years ago
In C# why use Protocol Buffer over the XML or binary serializes?
评论 #12187635 未加载
评论 #12187553 未加载
评论 #12187646 未加载