3 ms·
I see many comments here on the efficiency of binary formats versus JSON. While it is certainly possible, especially with a well designed and implemented protoc
by matharmin 9y ago
I see many comments here on the efficiency of binary formats versus JSON. While it is certainly possible, especially with a well designed and implemented protocol, just remember that you don't automatically get massive gains by using a binary protocol:
* JSON compresses well, and gzipped JSON is usually smaller than a corresponding binary format without compression.
* Being such a common format, practically every language has a highly optimized JSON parser. Just because a binary format can be faster to parse, doesn't mean the implementation is necessarily faster.
As a specific example, I've had experience in the past where the most common protobuf implementation for Ruby at the time was an order of magnitude slower than the default JSON parser (it has probably improved by now).
So by all means use a binary format for (internal) machine-to-machine communication if the performance gains are significant, but don't just assume that JSON will be too inefficient.
- alfanick 9y ago"Just because a binary format can be faster to parse, doesn't mean the implementation is necessarily faster." - except "JSON compresses well, and gzipped JSON is usually smaller than a corresponding binary format without compression", gzip takes some cycles...