Post by Pascal J. BourguignonPost by Ian CollinsPost by Generic Usenet AccountGreetings,
Can someone kindly point to some good links that are devoted to the
text vs binary protocol debate for distributed processing? I work in
a standards body that is currently debating this issue for M2M
(machine-to-machine) ecosystems. We are debating whether resource
constrained devices should support a binary protocol or an XML-free
text protocol. Any personal insight from the members would also be
welcome.
A lot depends on how constrained the machine is. If you use XML, it
also depends on the complexity the XML dialect (for example compare
XML-RPC to SOAP).
I used to use binary protocols in distributed systems, then I switched
Easier to monitor.
Easier to debug.
Easier to extend.
The price was verbosity.
Now I favour JSON, which is widely used in web based applications (a
common M2M ecosystem). JSON offers all the benefits of an XML based
Less verbose
Easier to generate and parse.
Easier manipulate in code.
So if you want the convenience of a text based protocol on resource
constrained devices, consider JSON.
http://people.csail.mit.edu/rivest/sexp.html
(He's the Rivest of RSA).
I am not as fond of this system, as it sort of resembles S-Exps, and uses
the same name, but it seems to be a very different entity in some ways.
for example, it loses the aspect of being a direct transcription of a
LISP-style typesystem, ...
IMO, the typesystem is a much bigger aspect of the entity than that of
having a "similar" notation (the addition of size-prefixes, ... is very
unlike the original notation).
so, in my definition of the term:
lists are made out of CONS-cells, and the usual dot-equivalence exists.
(a 1 2 3)
is the same as:
(a . (1 . (2 . (3 . ()))
and 'a' is a symbol, which is separate from a string, and '1' is a fixnum.
in my uses, I often include keywords, which usually support either the
syntax ':foo' or 'foo:', where the later form is mostly a personal
innovation which exists for aesthetic reasons (IMO, 'foo:' looks nicer than
':foo'), and does not exist in most Scheme or Common Lisp implementations.
back when I had my own scheme implementation, IIRC they had slightly
different semantics, but most of my later uses have treated them as
equivalent.
I use XML a fair amount as well.
a binary XML coding is used for some things, and this seems reasonable
enough (saves space, and is faster to re-parse than text XML...).
in my case, JSON isn't used as much (in itself) since, although I use
BGBScript (personal/pet scripting language) which has basically the same
syntax as JS, it would be a little wasteful to use the BS parser/interpreter
to parse data (slower, more garbage, ...). granted, a mini parser/printer
dedicated to JSON could make sense (although, in my implementation, there is
some overlap with my S-Exp printer/parser, which handles most of the same
syntax as both).
in this case, the real difference between S-Exps and JSON is the types used,
and the notation allows some hybridization, although BS/JS code fragments
will not parse in the S-Exp parser.
obj={a: (b 1 2 3) c: #(4 5 6) d: [7, 8, 9] }
typeof(obj.a) => "_cons_t"
typeof(obj.b) => "_array_t" ("array")
typeof(obj.c) => "_array_t" ("array")
typeof(car(obj.a)) => "_symbol_t" ("name" or "symbol"?)
typeof(cadr(obj.a)) => "_fixint_t" ("number", note: "_fixint_t"==fixnum)
yeah, the exact names returned by 'typeof' are sort of a current unresolved
issue between BS and JS (not yet thought up an optimal solution to this one,
among other issues WRT standards conformance: numerical precision issues,
some differences in object semantics, ...). but, good enough for my uses...
but, yeah, one would have to choose a specific type subset and notation
(either a Lisp-like subset, or a JS-like subset, say for S-Exps or JSON),
nevermind the whole matter of "byte[]" or "int[]" arrays, ... (BS also has
these, it lacks built in syntax support so things like "new byte[32]", ...
will not work at present, leaving me to call into C land to create them...).
but, yeah, JSON seems like a sane option as well IMO...
or such...