News for hackers. Stuff that matters.
Re:Using Protobuf instead of JSON to communicate with a fron... by rikrassen on Friday June 05, 2015 @11:40AM (#9666152)
One of the comments on that article was "YAY! JSON is wastefully large. I'd love to replace it." Is this true? I'm confused why JSON would be seen as a wasteful as a format. It seems to be that with any decent compression I would think it's hard to get much smaller. In this case I'm not talking about the other advantages Protobuf offers, I just want to know about size.
Re:Using Protobuf instead of JSON to communicate with a fron... by shanemhansen on Friday June 05, 2015 @01:41PM (#9666801)
There are basically 2 areas where JSON is really wasteful. Compression can help with both of those.

  1. Dictionary keys are repeated when you have an array of similar objects.
  2. Non-text data. JSON can't natively represent binary data, forcing people to use things like base64 for binary and base10 for numbers.
Re:Using Protobuf instead of JSON to communicate with a fron... by rikrassen on Sunday June 07, 2015 @01:08PM (#9675459)
I hadn't considered binary data. Thanks.
Re:Using Protobuf instead of JSON to communicate with a fron... by alkonaut on Friday June 05, 2015 @04:33PM (#9667944)
> "YAY! JSON is wastefully large. I'd love to replace it." Is this true? I'm confused why JSON would be seen as a wasteful as a format.

It transmits type and field names. Depending on how complex your data is those strings could be a large part of the data.

{ "person": { "age": 30, "shoesize": 10 } }

The above is what, 4-5 bytes of protobuf? I'm not sure what the gzipped-json data is but likely a lot more. If you were to send a list of 100 such person objects, the difference would be smaller.

Re:Using Protobuf instead of JSON to communicate with a fron... by haberman on Friday June 05, 2015 @05:08PM (#9668186)
> The above is what, 4-5 bytes of protobuf?

Assuming the integer fields are regular varint types (and not the "fixed" integer encoding), and assuming the tag numbers were all under 16, then this would be a six-byte protobuf.

Re:Using Protobuf instead of JSON to communicate with a fron... by alkonaut on Friday June 05, 2015 @05:21PM (#9668257)
Thanks. Admittedly a favourable example for protobufs but it shows the point: the names aren't data.
Re:Using Protobuf instead of JSON to communicate with a fron... by haberman on Friday June 05, 2015 @05:35PM (#9668327)
Yep! This improves decoding speed too.
Re:Using Protobuf instead of JSON to communicate with a fron... by maratd on Friday June 05, 2015 @11:43AM (#9666168)
> Is this true?

No, it isn't true, but regardless of what format you use, there will always be someone who's not happy. Actually, I think that applies to everything in life.