Boost logo

Boost :

From: John Maddock (jz.maddock_at_[hidden])
Date: 2024-10-07 08:07:00


>> Should Boost have kept C++03?
>>
>
> This question illustrates a lack of understanding regarding C++
> backwards compatibility.  I have posted an explanation of this at
> least a dozen times.  People don't get it.  Here is the LAST time.
>
> a) Boost always required that a submission work correctly on the
> compiler/library standard existent at the time of submission.
>
> b) All subsequent versions of C++ compiler/library must be backwards
> compatible with all previous versions.  There have been only a handful
> of exceptions to this rule in the last 30 years.
Actually I disagree, there have been a handful of rather high profile
exceptions, which have required quite a bit of maintenance to make code
compatible with modern compilers.  The removal of std::iterator and
associated base classes being the most painful recent one.
>
> c) After acceptance, library maintainers may "upgrade" code to a later
> standard at their discretion.  However, they are not required to.  It
> should be obvious why this policy has to be the way it is. Were it not
> for this policy, many boost libraries would be out of boost compliance
> with the release of every new version of C++.  This would impose a
> huge unnecessary burden on library maintainers.  And we don't have
> enough library maintainers.
The last part is certainly true.
>
> d) Hence, a program written to be compatible with C++03 is (almost)
> guaranteed to function.
>
> As far as I know this policy has never changed in the history of
> Boost. Probably because it makes no sense to do so.  The recent effort
> to "deprecate" support for older compilers was a total waste of time
> and effort and added nothing to boost.

It is certainly true that it's pointless to change code that is working
well.  However there are circumstances where some modernization is
extremely useful, to pick some random examples from Boost.Math:

* C++11 thread safe static variables are a huge win in code
simplification and runtime startup cost (we have lots of tabular data).

* Post C++11 meta programming is a lot easier on the compiler (shorter
compilation times) than C++03.

* Post C++17 would let us replace tag dispatching with "if constexpr",
which is easier to read and quicker to compile.

* We do occasionally get bug reports along the lines of "this code is so
last century, please modernize".  Unless there is a compelling reason to
do so we (or at least I) tend to resist until there is other maintenance
going on in that file, but generally removing C++03'isms makes the code
easier to grok.

* Younger programmers (the ones we need to encourage to join) don't have
a clue about C++03 style code, and just wonder why the heck you're not
using lambda's and auto everywhere etc. Eventually my C++03 code will
look like F77 does to me: so hopelessly outdated that no sane person
would ever want to work on it.   Sad but true!

Best, John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk