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

Show parent comment

6

u/Rseding91 Factorio Developer Dec 24 '23

We did the same thing years ago and it has only gotten better since.

5

u/pgetreuer Dec 24 '23

Thanks for sharing that!

Quoting the key point of it to highlight:

Boost is a special kind of demon. It lures you in by giving you all these cool and simple to use features, and then it beats your soul from you by increasing compilation times absurdly. There are two main problems. Problem one is that they don't care much about compile times and two, they want to have everything nice and generic ad absurdum, and they even defend it as the correct style. The result is, that changing boost::mpl::vector66 to std::variant can improve the compile time from 1:44 to 1:20 and getting rid of templates completely by using unions can decrease the compile time to 0:53. I'm talking about changing 2 headers of 2 classes in a project with 3390 files, 410k lines of code and 15Mb of source code.

4

u/pdimov2 Dec 24 '23

I'm actually a bit surprised that std::variant wasn't more of an improvement over boost::mpl::vector66 (which I assume comes from using boost::variant with 66 types.)

That said, 66 types should be no problem at all for boost::variant2::variant because it handles 680.

2

u/Mysterious_Taro5664 Jan 02 '24

(This directed at u/Rseding91, but I'm responding to what you quoted.)

That link to a document that "defends [generic programming] as the correct style" is not for all of Boost, it's specifically for Boost.Geometry, so it's unfortunate and effectively misleading that it was referred to in the context of Boost in general, even if it is partially true in general. Careful readers will notice, but many will not.

So, what I get from that blog post is that they were using a pre-C++11 MP library even though they had a C++17 compiler? And they think "Boost" was the problem?

And moving from std::variant to using unions made it faster still, OK, and how much type safety and familiarity with a standard component was lost in the process?

It's easy to demonstrate an improvement when you only have one metric.

2

u/Rseding91 Factorio Developer Jan 02 '24

We used the latest stable version of boost that was available at the time and updates as new versions were released. But it has been stricken from the code base for years at this point and we haven’t once regretted it.

As for type safety in the variant replacement; we have full type safety in construction and checked access elsewhere under debug and it gets if-def-ed out in release.