boost serialization vs google protocol buffers?

0xC0DEFACE picture 0xC0DEFACE · Jun 30, 2009 · Viewed 25.5k times · Source

Does anyone with experience with these libraries have any comment on which one they preferred? Were there any performance differences or difficulties in using?

Answer

ndfred picture ndfred · Mar 28, 2010

I've been using Boost Serialization for a long time and just dug into protocol buffers, and I think they don't have the exact same purpose. BS (didn't see that coming) saves your C++ objects to a stream, whereas PB is an interchange format that you read to/from.

PB's datamodel is way simpler: you get all kinds of ints and floats, strings, arrays, basic structure and that's pretty much it. BS allows you to directly save all of your objects in one step.

That means with BS you get more data on the wire but you don't have to rebuild all of your objects structure, whereas protocol buffers is more compact but there is more work to be done after reading the archive. As the name says, one is for protocols (language-agnostic, space efficient data passing), the other is for serialization (no-brainer objects saving).

So what is more important to you: speed/space efficiency or clean code?