encoding/gob use reflection? As that would probably be too slow for my use-case, and unnecessary considering the structure of the data is constant.I was wondering what the best option would be for sending binary data (structs containing ints and slices of struct{int, int} pairs, in this case) over tcp to clients written in other languages? It would be great for instance if there was a C library for decoding structs encoded in Go's gob encoding format.
On a related note, doesencoding/gobuse reflection? As that would probably be too slow for my use-case, and unnecessary considering the structure of the data is constant.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm sending those pairs as part of a data interchange format between a server written in Go and clients written in whatever language the users want to write in. The ints represent resource and property identifiers and values.
Simplified: http://play.golang.org/p/Yn8Xe4-XI
I was wondering what the best option would be for sending binary data (structs containing ints and slices of struct{int, int} pairs, in this case) over tcp to clients written in other languages? It would be great for instance if there was a C library for decoding structs encoded in Go's gob encoding format
Thanks everyone! I think I'll probably go with either Cap'n Proto or msgpack (which seems to support quite a variety of languages); when I get closer to implementing it I'll maybe benchmark them to see if either's significantly faster.
On Thursday, June 26, 2014 5:13:43 AM UTC-7, Jonathan Barnard wrote:Thanks everyone! I think I'll probably go with either Cap'n Proto or msgpack (which seems to support quite a variety of languages); when I get closer to implementing it I'll maybe benchmark them to see if either's significantly faster.
Hi Jonathan,
I like capnproto alot, and even maintain the go bindings for capnproto; let me know if you have any questions.
Msgpack doesn't provide a schema. If you appreciate (or insist upon) compile-time error detection, or want version-evolution support (i.e. forward and backward compatibility as you add or rename fields in your structs over time), then the schema-with-compilation style serializations, like capnproto, protobuf, and thrift, are better choices. For the rest of the discussion, I'll assume that version evolution and strong type discipline are required, and neglect the more dynamic and loose formats.
For me, the decisive feature in using capnproto were (1) performance; (2) graceful version evolution; and (3), that I can easily convert a text/human readable lisp-like description of a struct into binary-encoded data. This third feature is novel and under-appreciated, but it lets me construct type-checked DSLs for configuration and computation specification with ease. See the support for constant expressions in particular (http://kentonv.github.io/capnproto/language.html#constants).
Comparing capnproto, protobuf, and thrift (all three are fairly similar): capnproto's Java bindings were initiated last month, and are unfinished. If you need Java support today, then you are looking at protobuf or thrift. Also to note: capnproto on Windows works with mingw, but there isn't Visual Studio support at the moment, given microsoft's lagging c++11 support. So if you need Visual studio on windows support today, capnproto is not for you.
Re Thrift: I don't know how good the go-bindings are for Thrift. My sense (e.g. https://groups.google.com/forum/#!topic/golang-nuts/MgELd_iOaI8 ) is that Thrift sees little usage from Go, although the integrated RPC and great multi-platform support for Thrift (e.g. very good on Windows) may be compelling reasons to evaluate the various Go bindings out there.
In conclusion, protobuf is probably the safest choice for cross-language (and cross-platform) serialization and schema-evolution; but capnproto has given me better performance, smaller binary sizes, and declarative, type-safe, DSL support. This last was the decisive feature for me.
Best,
Jason
Just to throw my 2cents into the mix: I have been using the official go thrift bindings for a little while now and they have been working just fine. I have had to make sure to generate my thrift bindings using a 1.x generator. But other than that, its been good:
On Thursday, June 26, 2014 5:13:43 AM UTC-7, Jonathan Barnard wrote:Thanks everyone! I think I'll probably go with either Cap'n Proto or msgpack (which seems to support quite a variety of languages); when I get closer to implementing it I'll maybe benchmark them to see if either's significantly faster.
Hi Jonathan,
I like capnproto alot, and even maintain the go bindings for capnproto; let me know if you have any questions.
To be clear, microsoft's c++11 slowness only impacts your clients if they want to access your data in the following 3-pronged scenario: from (a) C++ code that is (b) on Windows and (c) insists on building with Visual Studio. Any other combination is unaffected. If you can use mingw on windows for your c++ clients, you are fine.
There aren't any Clojure or Haskell clients (or Java, as mentioned) bindings for capnproto at the moment. Were you wondering about the scenario if one of your users decided to first make capnproto bindings for these languages? That would, after all, be a pre-requisite to using your data if your data was encoded in capnproto and you wanted (say) Haskell code to read it.
Since you are asking about msgpack, it may be worth reviewing the tradeoff: the tradeoff lies in versioned-structs versus using a dynamic-map. That is the core difference. The reason, we are told, that google uses a serialization format with forward and backward compatible schema evoluation, is that they need to upgrade large clusters in a piece-meal fashion. It is impractical to upgrade an entire world-wide cluster all-at-once without incredibly long downtimes. You may have a similar situation with your users: do you plan to add features to a central server, and have that new server code still work with old clients that may be online and talking to it? If so, then msgpack would put you in the situation (as with json) where you have to use maps for everything. This imposes a performance penalty on retrieving elements of the map (when compared to looking up a field in a struct), and requires that you and your client write lots of field checking code to deal with absent and/or unexpected values. Again, the question comes back to: are you read-latency sensitive, and wishing to skip the whole parsing-and-deserialization step? Since capnproto lays out data on disk exactly as it will be laid out in memory, there is no parsing step, and your reads can go screaming fast.
On Monday, 30 June 2014 16:57:29 UTC+10, Jason E. Aten wrote:To be clear, microsoft's c++11 slowness only impacts your clients if they want to access your data in the following 3-pronged scenario: from (a) C++ code that is (b) on Windows and (c) insists on building with Visual Studio. Any other combination is unaffected. If you can use mingw on windows for your c++ clients, you are fine.
I suppose what I should be asking is whether there is (or is likely to be in the near future) a binary distribution of capnproto, as that would greatly simplify installation on Windows clients. The installation page doesn't seem to provide one.
It's impossible at the moment for visual studio to compile capnpc and the runtime libraries due to the use of c++11 in the capnpc source code, the runtime libs, and the generated c++ source itself. People were hopeful that vs2013update2 would be sufficient, but apparently it will not be (relevant discussion: https://groups.google.com/forum/#!searchin/capnproto/c$2B$2B11/capnproto/IK4zj_aVvOM/gaIFEp5kdRQJ ). The missing features are constexpr member functions and unrestricted unions. I'm sure someone will post a binary as soon as microsoft makes it possible.