On Friday, November 25, 2011, Joe Armstrong <<a href="mailto:erlang@gmail.com">erlang@gmail.com</a>> wrote:<br>> I guess you all know about Chinese whispers. <br>> You send a whispered message round a circle and see if you get the same<br>
> message back.<br>> The computer variant is as follows:<br>> Send a complex data structure round a circle, and see if you get the same message back.<br>> The circle is a ring of processes written in *different* programming languages.<br>
> The message is a complex message, containing primitives such as integers, booleans<br>> and strings and constructed types "sequence of" "tuple of" etc.<br>> Messages are sent over sockets. I want each language to unpack the message into the<br>
> internal form that is appropriate for that form, and then reconstruct the message from the internal form.<br>> This is something that I think *should be very easy* but is in fact very difficult.<br>> In a previous post I outlined how Erlang could talk to javascript but this method is not  simple<br>
> and not compete - it would break done, for example if the integers were bignums.<br>> What should we use for the internal form? JSON is untyped so will give us lots of problems.<br>> ASN.1 is great but badly supported in many PLs - xml? - but the schemas are horrible.<br>
> Thrift? - Google protocol buffers ... some kind of self-describing binary format would seem<br>> appropriate - bert for example.<br>> I really would be nice to solve this problem is the simplest possible way so that it<br>
> was very easy to send whispers round a circle and get back what you sent.<br><br>If you simply consider JSON to not support bignums, then there is no data lost in the interchange once you've given up on representations that don't have a 1:1 mapping to JSON. JSON isn't really the problem, it is typed it just doesn't have all of the types you may want in the spec but that doesn't stop you from extending objects to carry other types (see JSON-RPC), Bert does this a bit too. The problem is then simply how to meaningfully deal with these things in N languages, but for your use case you could cheat and not try and do anything meaningful. <br>
<br>I can't imagine an interchange format that was everything to every language, but you can certainly define subsets that represent a common denominator that is good enough for many purposes. For example, in Python it's valid to have a loop in your object graph and serialize it with marshal or pickle, but there's not an obvious representation for that in a functional language like Erlang. Consider: lst = []; lst.append(lst)<br>
<br>-bob