View Single Post
  #4 (permalink)  
Old 08-08-2011, 06:37 PM
Bjoern Hoehrmann
Guest
 
Posts: n/a
Default Re: Which data serialization format?

* Tobias Nissen wrote in comp.lang.perl.misc:
>Sorry, I forgot to mention it, but I like the idea of the format to be
>programming language independent. Thrift e.g. seems to officially
>support 14 different languages, which was one of the reasons why I
>picked it for my experiments.
>
>I also dislike the absence of basic types (like String, Int, Bool, ...)
>when using Storable. Or the the fact that I'd have to write a type
>checker myself. Also there are no schemas and hence no automatic code
>generation. It's all too dynamic for my use case.


The types are there just as they exist in Perl, and you can use any tool
that is compatible with the type system for things like validation. It's
just bits on the disk, but with all serialization formats you get things
like "dictionary with key string example and value number 1" in memory;
JSON::Schema for instance does not require you to pass in actual JSON.

The popular formats with good tool support in Perl are YAML and JSON and
for both you'd have to use an encoding like Base64 to reliably serialize
binary data (YAML though allows you to tag values as Base64-encoded, so
in theory the support for binary data is better there, but tool support
for that is a bit lacking).

Note that Perl itself does not distinguish between text and binary, you
will have to include logic for that in the code regardless of the format
you pick, if you actually need to tell those cases apart (if you do not
care, note that U+0000 through U+00FF are perfectly valid characters and
can be represented easily in either format; in that sense both support
binary data quite well).
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Reply With Quote