home | library | resume

Protocol Buffers, gRPC, and JS/TS - a Rant

2023 Oct 07


Protocol Buffers and gRPC are amazing. But also, fuck them.


Google built Protocol Buffers a long time ago, and the competitive landscape of solutions was very different at the time. Even as I write this, in 2023, https://protobuf.dev still has this as the intro text to protobuf:

Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.

XML? Seriously? There's a lot more than SOAP out there these days.


Protobuf went through a lot of iterations internally at Google before it was open-sourced (I wrote go/wtf-are-protos when I was there to make sense of it, because I had the distinct pleasure of being on a team that was on the long tail of proto1 users who couldn't move to proto2).

This meant that, before being open-sourced, it was designed to solve Google problems, created by Google scale, for Google engineers. And actually, I should really say it was designed to solve google3 problems by google3 engineers.

This also meant that after being open-sourced, it... kind of continued to stay that way.


Let's step away from the history of protobuf for a second. Here's the problem that we've dealt with at trunk.io for the past few years:

Now, in theory, using Bazel should've made it easy to get going with protos and gRPC: having intermediate codegen steps and modelling them in the dependency graph of your build system of choice (to the extent that you're willing to describe your Lovecraftian Makefile horror as a build system) is always a pain. (At least, I assume so. I've never actually had to set up Makefiles for anything that wasn't a toy.)

In practice?

And so that's how we at trunk.io have been stuck with a hideously un-ergonomic protobuf API and tooling setup for the past 2 years with an inability to get off this.

P.S. what the frickity frack is going on with the runtime libraries here? grpc doesn't receive security updates anymore and you're supposed to use @grpc/grpc-js now. Except there's no actual published documentation for @grpc/grpc-js, and you're supposed to use the grpc docs instead (fortunately the two appear to be mostly API compatible, but I don't have a good sense of the edge cases where we do have divergent behavior.)


I blame Google for this state of affairs. (And now that I'm on the outside looking in, it's easy for me to throw stones at glass houses - I'm sure some of the stuff I'm about to say is blatantly wrong because there are .)

Google had to figure out Javascript in the early 2000s, when they were inventing Gmail and the notion of a Web UI that wasn't just a pre-compiled Xanga blog or something. That led to Closure, which... worked. Right up until the rest of the Internet got big and people started loading bigger pages on beefier machines.

Fast forward to the early 2020s, and Google has managed to make bad bet after bad bet in frontend/JS land:

And as a consequence, the JS tooling - and TS tooling as well - has just never been properly developed. I suspect organizationally, the protobuf team was also never appropriately staffed to make JS/TS development sane, which is why the rest of the open-source world has had to pick up the slack here (in fact, when I was at Google, the only team staffing that I remember existing for protobuf was for getting google3 off proto1 - I don't think their mandate allowed them to tackle any major projects that weren't "rip out all the dependencies on XYZ legacy technology").


I don't really have a conclusion here. This piece has just been floating around in the back of my mind for a long time, in some shape or form, and I wanted to get the ideas and thoughts out in words.