Protocol Buffers vs. Thrift

I’ve been playing around a bit with Protocol Buffers and Thrift. Thrift has many more features:

  • generates RPC service implementations (PB only generates the interfaces); currently targets libevent
  • targets more languages
  • constants
  • exceptions
  • multiple protocols (binary, JSON)
  • asynchronous procedures
  • more collection types, such as maps/sets; this makes it easier to use the messages directly as the primary representations of your program’s data

Despite Thrift’s additional features, for the small project I’m currently working on, I’m going with PB. Some reasons:

  • (at least for C++) the interface to reading/writing messages feels “lighter”: you don’t need to manually contsruct transports/protocols/etc., heap-allocate and wrap things in shared_ptrs, perform copies to get at the data inside a TMemoryBuffer (unless you write your own TTransport), and so on.
  • PB is a more mature tool than Thrift
  • documentation
  • not as fast or as compact as PB
  • weaker encapsulation: it exposes public fields and uses the language’s standard library containers, which precludes tricks such as backing messages directly with the serialization buffer
  • small annoyances, such as not having packages for and not building cleanly on Ubuntu 8.10

Follow me on Twitter for stuff far more interesting than what I blog.