MessagePack: Efficient, Cross Language Binary Object Serialization
MessagePack GitHub repo is a new binary-based object serialization protocol and library built with efficiency and speed in mind. Developer Sadayuki Furuhashi presents it as a faster alternative to JSON that has similarly broad support across several popular languages.
Serialization is the process of taking an object (such as a string, hash, or even something of your own creation) and turning it into a single time of data that can be transmitted down a network connection, stored in a file, or similar. Protocols like JSON, YAML, and XML are commonly used for this purpose, but for the highest efficiency, binary protocols are an alternative. One option available to all Ruby developers (as it's in the standard library) is the Marshal library but this protocol isn't cross-language friendly (or even between some Ruby versions).
To demonstrate MessagePack's speed, the developer presents the results of a benchmark where 200,000 objects made up of three integers and a 512 byte string were serialized and deserialized once each:
While Ruby is the focus, there are also libraries for Python, Perl, C/C++, Haskell, and Lua ready to roll.
Installation and Example
To install MessagePack:
gem install msgpack
require 'msgpack' msg = [1,2,3].to_msgpack #=> "x93x01x02x03" MessagePack.unpack(msg) #=> [1,2,3]