Subject: Re: [boost] [serialization] clarify in doc on overview that library does not aim for inter-process communication nor for backward compatibility
From: Robert Ramey (ramey_at_[hidden])
Date: 2019-04-18 17:11:31
On 4/16/19 10:26 AM, rafalcpp--- via Boost wrote:
> Some developers expect archiving or serializing libraries to be backward
> compatible, for example if I simply save vector<string> to a JSON, then
> files written from program with more modern json library will be
> readable on older one and vice-versa.
minor confusion - boost serialization doesn't support json format.
> Boost serialization is instead rather intended to read files
I'll speak to the intentions of the library author - me.
> created by
> same program with same boost version (or read it on a more recent, but
> not on older, version of boost).
There are several "versions here":
a) the version of boost
In most cases the version of boost should not make a difference. In
some cases the serialization of primitives does vary depending on the
version of boost. These are backward compatible only. That is, if has
fallen into this case, an archive created in one version of boost may
not be readable with a previous version of boost. I don't think such
cases are very common however.
b) the version of the standard library
this should not matter to anything.
c) the version / brand of the compiler
this should not matter - serialization code is compatible back to C++03
d) the version of the class being serialized
this is under control of the application programmer. So if the serialize
function has not changed, older versions of the library should still
work - subject to a) above.
e) the main program invoking serialization
if a class has serialization defined, it should work in any program in
which this the header for this class has been included. Actually this
is not quite true. In some cases, the serialization changes if the
class is serialized anywhere though a pointer. This is now recognized
as a design mistake. But it doesn't seem to come up in practice often -
if at all.
To summarize, the intention is that boost serialization be backward
compatible in every way. It is mostly forward compatible as far as code
is concerned. forward compatibility in class definitions/serialization
functions is not supported.
> Could we clarify this with a warning on the Overview page?
I'll consider this. Since I won't get to it right away, perhaps you
would prefer to submit as an issue on the serialization git repo so that
it won't get forgotten.
Given the above, you might want to refine your submitted text.
> Perhaps something along this lines:
> Warning: please note that the format version may change with
> boost.archive library versions, an old program may not be able to read a
> format that was designed after it was build.
> Explanation: some archive libraries offer long lasting forward and
> backward compatibility of the archived data.
> For example if your program saves list of book titles into a JSON file,
> then if your main program itself does not change you can expect to
> always be able to load that json file - even when loading it on old
> version of JSON library while archive was saved on a very new one.
> This is however *not* the case for this boost archive library (at least
> for the default archive classes) - here even if your main program stays
> the same then archives written on one using more recent libboost might
> be unreadable on ones using older libboost.
> This also means that communication between users (e.g. over Internet) by
> exchanging archives created by this library will not work in case if
> users build the program on their own and build it against different
> versions of boost.
> Although, a work around exists in form of including specific version of
> boost serialization library, and freezing that version, in your program,
> if you are willing to stick to one version of this module.
> Please correct if there are any mistakes (for example if that is
> possible in some special way).
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk