Live data from Hacker News

You're Using JSON, Why not MessagePack?

blog.andrewvc.com

31–40 of 66 posts

Re: You're Using JSON, Why not MessagePack?

#31

I'm not using JSON or MessagePack because I need to send arbitrary binary data. I understand why people use JSON, and it has its domain (sending data to and from the browser), but in other situations I don't think it is a good protocol. Another poster mentioned tnetstrings, those look interesting, however I am not sure how well those would handle binary data.

Messagepack is built to handle arbitrary binary data efficiently

Re: You're Using JSON, Why not MessagePack?

#32
post #13
post #5

Because it isn't human readable, which will make debugging it far less convenient than glancing at some JSON in a browser (or in Firebug).

This. Never liked nor used XML for that exact reason.

Rather than down vote you for a simple mistake, I thought I'd let you know that xml is just as human readable as json.

Re: You're Using JSON, Why not MessagePack?

#33
post #25
post #23

Earlier quoted context omitted.

bson messages are often larger than their json counterpart. The benefit of bson isn't size, but rather ease (on the cpu) of serializing and deserializing.

I agree in part. Most of the time JSON and BSON are very similar in size, and sometimes larger (due to length prefixes). But, size benefits do emerge when you need to store binary data inside the object. Instead of a base64 encoded string, the binary data can be stored directly.

Yeah, GridFS would be pretty silly in JSON.

Re: You're Using JSON, Why not MessagePack?

#34
I have a naive question - why would I not use something like ZeroMQ for messaging ?

I completely understand the need for JSON when you are communicating with the frontend/Javascript. But if you are doing backend messaging, would you not rather use ZeroMQ (which comes with its own protocol).

From what I understand (from previous HN posts), it is super fast and handles binary data very efficiently. I also understand that you can tune stuff at the OS level to wring the last bit of performance from ZeroMQ.

P.S: yup, it is written in C, but all bindings apparently work very well.

Re: You're Using JSON, Why not MessagePack?

#35

I have a naive question - why would I not use something like ZeroMQ for messaging ? I completely understand the need for JSON when you are communicating with the frontend/Javascript. But if you are doing backend messaging, would you not rather use ZeroMQ (which comes with its own protocol). From what I understand (from previous HN posts), it is super fast and handles binary data very efficiently. I also understand th…

They're different types of thing. ZeroMQ doesn't replace JSON, it replaces HTTP. If you're using ZeroMQ it will help you get some bytes from one place to another, but you still need a serialization format. You might well send JSON over ZeroMQ.

Re: You're Using JSON, Why not MessagePack?

#36

For the same reasons we are in the process of switching from Protocol Buffers back to JSON: * It does not support our languages. Is there a Ruby module with no C extension? A C# library? Lua? What about that really cool language coming out next week? What about C? * Even if it does, why have to deal with someone else's poor API design? JSON has a million parsers for everything, and if by chance you don't like any of…

> Is there a Ruby module with no C extension? Why is the "with no C extension" part important to you?

By the way, there is a pure ruby version, not sure why you'd use it over the cext though:

https://github.com/hiroshinakao/msgpack-pure

Re: You're Using JSON, Why not MessagePack?

#37

The "4x faster than Protocol Buffers" claim is misleading, as I have explained before: http://news.ycombinator.com/item?id=2146147 I'm working on a Protocol Buffer library that can serialize/deserialize to either JSON or Protocol Buffers. That way you can do all your development with JSON, but if you ever find you need the efficiency improvements of a binary format, you can just change your Serialize() call. Having a…

This sort of "scientific dishonesty" is prevalent everywhere. I'd be surprised if the test creator didn't go out of their way to design the test specifically to push their agenda.

It's sad, really. The people who try to call bullshit on those sorts of claims are frequently drowned out by those who are blinded by the "4x faster!" etc.

Re: You're Using JSON, Why not MessagePack?

#38

I'm not using JSON or MessagePack because I need to send arbitrary binary data. I understand why people use JSON, and it has its domain (sending data to and from the browser), but in other situations I don't think it is a good protocol. Another poster mentioned tnetstrings, those look interesting, however I am not sure how well those would handle binary data.

I wouldn't say JSON's main domain is sending data to the browser - I'd say it's exchanging common data structures (lists, hashes, strings, numbers) between environments, including between different languages. Sure, it doesn't make sense if you're shipping binary blobs around, but most of the time you're probably dealing with lists, hashes, strings and numbers.

Re: You're Using JSON, Why not MessagePack?

#39
post #35

I have a naive question - why would I not use something like ZeroMQ for messaging ? I completely understand the need for JSON when you are communicating with the frontend/Javascript. But if you are doing backend messaging, would you not rather use ZeroMQ (which comes with its own protocol). From what I understand (from previous HN posts), it is super fast and handles binary data very efficiently. I also understand th…

They're different types of thing. ZeroMQ doesn't replace JSON, it replaces HTTP. If you're using ZeroMQ it will help you get some bytes from one place to another, but you still need a serialization format. You might well send JSON over ZeroMQ.

Here's my specific doubt - my application uses arrays, maps, lists, etc. Can I not use zeromq to send these data-structures as binary data rather than serializing them to JSON ?

Re: You're Using JSON, Why not MessagePack?

#40
post #27

Because JSON is around twice as fast to encode/decode in Node, which is where I really need the performance. MessagePack is just slow, complicated, and unnecessary.

Citation needed, especially since the node-msgpack library docs say it's anywhere from 1.2-3X faster. https://github.com/pgriess/node-msgpack

Good point... a Node MQ project formerly based on msgpack recently switched to JSON and increased its performance by almost 200%: https://github.com/aikar/wormhole/issues/3

I've done several of my own benchmarks as well and can confirm that the current Node JSON implementation is much faster than MessagePack. Their benchmarks are most likely quite old.

Post reply on HN