Protocol Buffers is Google's standard for binary serialization of objects.The name of course is very misleading, it denotes a singular concept, not a plurality, and it has nothing to do with buffering the protocols or protocolling the buffers, as the name may suggest.

PB is comprised of

  1. a cross-platform-compatible wire format for binary serialization of objects,
  2. a declarative language (known as Proto) used to define your domain-specific structures (objects), and,
  3. a cross-compiler that can turn the above declarative specification into a program in an imperative language that would implement the parser/serializer

This sounds complex, but what you actually get is a tool that takes .proto file and spits out a source code file that you can use to read/write your objects. Most .NET developers should be familiar with this paradigm back from xsd.exe and wsdl.exe days.

Here's how typical .proto file looks like (from this Overview page)

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

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

PB is used in situations when you want to go binary for super speed and small size but don't want to loose the extensibility/compatibility that XML used to allow. With PB you can define new versions of the same structure with extra fields added and have past versions of the parser happily ignore the new fields. Just remember that Protocol Buffers wire format is NOT human readable unlike XML or JSON, although you can produce a human readable dump of what would go onto the wire, e.g. for debugging purposes.

While native PB compiler originally implemented by Google could only generate parsers / serializers in C++, Java or Python, there are now 3 .NET ports:

  • dotnet-protobufs by Jon Skeet. This is an implementation of the Proto compiler in .NET that can generate native .NET serializers / parsers. Ayende uses this one in his NH Profiler for both inter-process communication and for saving application state on disk. This version is very close to the original Google PB spirit, in the sense that you have to explicitly call methods to serialize/deserialize.
  • protobuf-net by Marc Gravell. To avoid writing yet another compiler, Marc has chosen an approach that requires you to decorate your .NET objects with attributes specifying serialization details. Ayende has criticized this approach as sacrificing compatibility / standard-compliance for the sake of being more developer friendly. On the bright side, it does fit in very nicely with WCF, allowing you to have WCF services speaking to each other in PB language.
  • Proto# - another alternative, not sure how good or bad this one is.

While Protocol Buffers seems to be just yet another format, it has a few distinct advantages. First, like I said above, it is binary and extensible at the same time. Second, it is binary and cross-platform compatible at the same time, and third, it is backed by Google, which people have a tendency to blindly follow like.