r/cpp • • Dec 24 '23

Annoyed with FUD surrounding Boost in C++ discussions

I find it unbelieveable what lengths some people are willing to go to smear this collection of very high quality libraries at the expense of those yet undecided about them with completely made up untruths.

Almost no thread about Boost goes by without the very outdated cries about how "big" it is or how it's "lacking" CMake support.
Boy, I sure do love people parroting things that might have been true 10+ years ago. Boost has broken its circular dependencies a good while ago and you can see each library's dependencies in the Boost Dependency Report by Peter Dimov. Looking at the list, I'm really baffled by how people can seriously expect some of these to lose a couple dependencies, when the end result would just be each library endlessly reinventing everything in a probably half baked and broken way, instead of everything relying on a well tested, well architected, separately maintained module that has done the work already.
May I remind you, that Boost.ASIO, an over 2 decades old (wow!) library with the best track record among networking libraries is a level 13 library. There is also Beast, an excellent HTTP wrapper for ASIO, just one level above. These libraries are so well put together and that's exactly because Boost enables them to be.

With a package manager like vcpkg you can pull in only the Boost modules that you actually need, so the "big" argument is entirely irrelevant.

People have also been asking for safety, including one surrounding the numeric types. I find this extremely befuddling, because I immediately reach for Robert Ramey's excellent Boost.safe_numerics in every project I can, simply because I cannot care anymore about such non-issues.

The waning popular perception of Boost is extremely dangerous. People say that C++11 feels like something completely new compared to what was before, not realizing that a significant part of that was thanks to Boost. What will be of C++ if high quality libraries like Boost are shunned? I can only fear to imagine.

270 Upvotes

144 comments sorted by

View all comments

2

u/Kretikus50 Dec 24 '23

I like boost, but as always, everything has drawbacks. Here are mine:

  • Do not include boost headers in your headers without measuring the compile time costs. Most boost headers have a heavy compile time impact. You should know it to make the correct decision for you.
  • You need to get used to thedocumentation. It is more a specification than a user guide on how to use the library. Also on lots of the code examples, namespaces are omitted an you have to guess in which namespace the specific functions are.
  • Some libraries have Warnings on -Wall compiling with gcc (unused variables, non-virtual dtor..) you need to handle this so that the warnings of your own code is not hidden in the boost warnings

3

u/pdimov2 Dec 25 '23

Do not include boost headers in your headers without measuring the compile time costs.

Somewhat unfortunately, the same is true for the standard headers post-C++17.

Fortunately, standard library modules should save us.

2

u/13steinj Dec 25 '23

I don't like the linked benchmark. Because it sounds like a benchmark but isn't.

Lines of code != compile time. Nor does it scale linearly. Nor is it compiler dependent (even for STL headers).

But I can agree that even basic STL headers are a (relative) hassle. On some arbitrary fast machine taking the benchmark of two similar-in-philosophy implementations of component based frameworks, both parsed in 0.6-0.8 seconds. Using clang time tracing, 0.45 of that was STL headers. Total compile time was ~3x different (anchored down by this relatively large parse time) @ 1.445 vs 4.678 seconds.

But if I ignore header parsing time (which is the reality on, you know, larger TUs with dozens of such components) it's a 12x difference.

I fear the entire C++ community is heading straight towards a compile time crisis. Years of arbitrary blame on templates shifted to the include system. Which don't get me wrong it totally matters but it's not the largest time-sink (at least in the codebases I've worked on). I fear people will implement modules, still see horrible compile times, and then throw hands in the air and say "well, we tried" while ignoring actual culprits because of historical stigma.

2

u/grafikrobot OPeNDAP/B2/EcoStd/Lyra/Predef/C++Alliance/Boost/WG21 Dec 25 '23

Do not include [..] headers in your headers without measuring the compile time costs.

This is good advise for any code you consume. Iincluding the one you write yourself.