I actually like tnetstrings for backend messaging, but I don't see it used very often. json is pretty damn ubiquitous these days.
I actually like tnetstrings for backend messaging, but I don't see it used very often. json is pretty damn ubiquitous these days.
If you are decoding a JSON string, you run over the string twice: first to search for the terminating quote character so that you know how much memory to allocate, and second to copy the string.
Whereas with msgpack, it's more like pascal-model strings where you know the length of the string up front; you can do it one pass. You also get some structural hints that make more of the parsing a parallelizable problem, whereas with JSON it is very difficult to get any benefit out of more cores.
This may not make any difference if you are serving up an API request or three to x86 computers with broadband, but they make a lot of difference if the data you're working with is large relative to the bandwidth or latency of the pipe or the CPU power available on the other side of it.
> For me the advantage of msgpack is simplicity / efficiency in parsing the response
If you like that, you might want to take a look at tnetstrings as a format.Also there's this gem:
> You are not allowed to implement any of the following features: UTF-8 Strings
glances at title of article
Edit: here are my results, which lack the numbers for msgpack except a mention at the end (I hate linking to Posterous, but I haven't moved my blog yet): http://nitrogen.posterous.com/164964342
Ok I gotta ask.... Why on earth would you do that? It seems like an exercise in masochism. I wasn't even aware that ruby would compile on embedded arches.
Mostly I wish people would agree on a schema and use ASN.1 PER, rather than choosing from the ever-growing list of binary type-length-value formats which put a redundant copy of the schema on the wire in every message (making them neither small nor readable). I've never had occasion to do anything useful with a message whose format wasn't already known when I wrote the code.
FWIW, I do very little "web work" (by which I assume you mean front-end?). Instead it is mostly api endpoints for mobile and server-to-server backend messaging. Lots of http transport stuff. If I were doing rpc, I would either not (and use a restful or type-2 api), or use something like protobuf or thrift.
Msgpack just doesn't seem, to me, as a really great fit for anything in particular.
>Msgpack just doesn't seem, to me, as a really great fit for anything in particular.
Pinterest disagrees: http://engineering.pinterest.com/posts/2012/memcache-games/
To give you some context, frsyuki developed MessagePack originally for RPC (he was building a distributed key-value store in college) and made a conscious decision not to add a string type for maximal cross-language compatibility. Like a lot of other technology, MessagePack has outlived its original purpose, and there is a lot of demand now for it to support the (utf-8) string type, not just byte array.
> "Lots of http transport stuff" is still "web programming" (for me, at least).
Web programming to me sounds like javascript and css. A the very least something to do with html output at some point. Oh well. > Pinterest disagrees: http://engineering.pinterest.com/posts/2012/memcache-games/
I didn't see any reference in that post to them trying compression. It would have been an interesting comparison.Good data point on usefulness though. Thanks for that.
I tried snappy, but found it was a) slower and b) bigger. Not having to have yet another dependency was also a plus for gzip.