talira

Protocol Buffers

Google's language-neutral, platform-neutral mechanism for serializing structured data

open sourceBSD-3-Clauseself-hostablefree

Protocol Buffers (protobuf) is Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data: like JSON, but smaller and faster, and it generates native language bindings. You describe messages once in .proto files, and the protoc compiler generates code to build, serialize and parse them in C++, C#, Java, Kotlin, Objective-C, PHP, Python and Ruby, with Google-supported plugins for Dart and Go. Fields can be added and removed without breaking old readers or writers, which makes it common for service APIs (with gRPC) and long-term storage. Google open sourced it in 2008 under a BSD 3-Clause licence.

Ways to install

Problems it solves

  • send typed data between services written in different languages without hand-writing parsers
  • the JSON payloads between my services are too big and too slow to parse
  • add fields to a message format without breaking older clients and servers
  • generate data classes for Java, Python, Go and C++ from one schema file
  • define the request and response messages for my gRPC services
  • store structured records on disk in a compact binary format that survives schema changes
  • share one set of message definitions across teams and projects

Features

  • .proto definition language with editions, proto2 and proto3
  • protoc compiler generates code for C++, C#, Java, Kotlin, Objective-C, PHP, Python and Ruby
  • Google-supported plugins for Dart and Go
  • backward and forward compatible schema changes
  • compact binary wire format and fast parsing
  • text format
  • shared definitions such as timestamp.proto and status.proto
  • prebuilt protoc binaries for Linux, macOS and Windows

Limitations

  • Not suited to messages larger than a few megabytes: it assumes a whole message can be loaded into memory at once3
  • Doesn't compress messages: compress them yourself, or use a format-specific encoding for images and similar data3
  • Messages aren't self-describing: you need the .proto file to fully interpret one3
  • Not a formal standard of any organization: unsuitable where rules require building on standards3

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known
Has official SDKsplan not known

Alternatives

The same job

These do what Protocol Buffers does.

  1. FlatBuffers A memory-efficient cross-platform serialization library
  2. Apache Arrow The universal columnar format and multi-language toolbox for fast data interchange

Compare Protocol Buffers with the top 3