[erlang-questions] binary typed schema-less protocol

Vincent de Phily vincent.dephily@REDACTED
Tue Jul 30 20:24:32 CEST 2013


On Tuesday 30 July 2013 13:44:37 Chris King wrote:
> On Tue, Jul 30, 2013 at 1:18 PM, Vincent de Phily
> 
> <vincent.dephily@REDACTED> wrote:
> > On Tuesday 30 July 2013 10:31:04 Chris King wrote:
> >> Color me confused, but doesn't only PER require a schema?  BER/DER/CER
> >> are all self-describing.
> > 
> > Only up to a point. When decoding, you'll know that you're dealing with,
> > say, an integer, but you won't know which field of the enclosing sequence
> > it corresponds to, if the fields are optional (that's just one example of
> > confusion, but there are more). So you can decode a squeleton of your
> > data, but it'll lack meaning.
> 
> This particular problem I thought was addressed by SET types with
> explicitly tagged members?
> 
> The shortcoming I *do* see is that the member tags must be integers;
> the advantage JSON has is that the tags may be strings.  Even then,
> string tags only aid humans, not machines.
> 
> This is a limitation to be sure, but I wouldn't say this makes the
> difference between a schema-ful and schema-less encoding.

You can do that, it'll feel like protobuf/thrift. But unless your data is 
actually properly described as a set of integer->value pairs, you've 
introduced a schema without noticing it. The decoder will have to know what 
the key 1 stands for, either hardcoded or by parsing the asn1 grammar.

It *is* possible to use asn1 BER as a schema-less format, if you follow some 
conventions. But that's fitting a square peg in a round hole. You can 
philosophize about what it means to be schema-free, but you'll still feel the 
pain when you use the wrong tool for the job. ASN1 is meant to be used with a 
schema.

-- 
Vincent de Phily



More information about the erlang-questions mailing list