Protocol buffers, an introduction

Table of Contents


Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. Some advantages are:

  • Cross platform and language independent
  • Backwards-compatible and future-proof
  • Focused. Proto schemas describe your data models.

Protobuf was invented by Google, and is a lot smaller and faster than other alternatives like XML.


message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

While using with Java, this can be used like this:

Person john = Person.newBuilder()
    .setName("John Doe")
    .setEmail("[email protected]")
output = new FileOutputStream(args[0]);

Seems easy, right?


  • The Builder notation can be used.
  • Less boilerplate code.
  • Easy to understand


  • Unreadable data
  • When the data model is not suited for a schema.
  • When data from service is directly consumed by the browser, this can be a problem.


Well, this looks interesting and I would like to know more about it. For now, I won’t be diving deeper, but will definitely consider using protobufs for my next project.


comments powered by Disqus