Google Protocol Buffers Or Something Similar For .net/javascript
Solution 1:
If the client is javascript, I think you'll struggle. There is (as you've stated) limited javascript coverage, but I'm not sure it will gain you a lot. To quote from Kenton Varda (who really knows protobuf):
One problem with javascript and protobuf is that you need a lot of support code to parse the messages. Unless you end up sending quite a lot of stuff back and forth, making the user download a JS protobuf codec library may be a net loss. It may be better to use JSON or XML because browsers already have built-in support for those.
That said, I think various people inside google have been playing with javascript + protocol buffers for awhile and if we end up with anything that works well enough, we'll release it.
So maybe there is hope down the road. For now I would stick with json + deflate, or if your scenario allows it you could perhaps use a Silverlight applet embedded in the client? protobuf-net will work inside Silverlight.
Solution 2:
You may find JSON is in fact the best answer. Justin has done a series of performance comparisons of JSON to Thrift and Protocol Buffers and found compressed JSON to be faster than protocol buffers, at least in Python. Here's an earlier thread on the topic.
Solution 3:
As mentioned, using binary protocols from javascript is problematic. Some specifically nasty aspects are:
- It is difficult to reliably access content as binary, from javascript -- work-arounds are typically browser-specific (see Accessing binary data from Javascript, Ajax, IE: can responseBody be read from Javascript (not VB)?)
- Encoding/decoding standard IEEE encoded double/float values is difficult and inefficient (if not downright impossible)
And performance is very unlikely to be faster, compared to native support for JSON or XML.
Post a Comment for "Google Protocol Buffers Or Something Similar For .net/javascript"