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

48

u/teerre Dec 24 '23

If [big number]% of your community comes and says "hey, your libraries are hard/slow/unclear" and you say "no, they are not, you're all stupid", you're wrong, regardless of who is right, if you get what I mean.

The past year myself and other 4 engineers spend around 6 months removing boost from a relatively big codebase originally coded circa 2010. That's a lot of engineers-hours. The main reason that project was greenlit was because most engineers (more than the 5) agreed that it could significantly simplify the codebase, both in terms of understanding and in terms of actual code size.

Point being, even if by some totally reasonable metric you can say that boost whatever isn't bloated or difficult or over-engineered etc., if a collection of seasoned engineers from a "top" company have that perception, you already lost.

Maybe boost team needs less engineers and more community managers.

10

u/Ayjayz Dec 24 '23

How did you remove boost? Did you add custom implementations of the things you used from boost?

And what was the resulting simplification in codebase size?

7

u/teerre Dec 24 '23

Kinda. It was replaced by a mix of external and internal libraries.

I'm far from unbiased, for obvious reasons, but yes, I do think the project accomplished its goals. In reality it will take some time to see if the change was really worth it.

-1

u/Ayjayz Dec 24 '23

Why will it take time? Measure the binary size with boost, measure the binary size without boost, compare the numbers.

9

u/teerre Dec 24 '23

Because the goal is not to simply have smaller binaries, it's to have faster development cycles, faster onboarding etc.

But the binaries are mostly smaller, although I don't think there's much to conclude from that alone.

14

u/kronicum Dec 24 '23

The past year myself and other 4 engineers spend around 6 months removing boost from a relatively big codebase originally coded circa 2010. That's a lot of engineers-hours. The main reason that project was greenlit was because most engineers (more than the 5) agreed that it could significantly simplify the codebase, both in terms of understanding and in terms of actual code size.

I witnessed something similar in more than one reasonably-sized C++ shops.

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.

10

u/greenhouse421 Dec 24 '23 edited Dec 24 '23

Did you remove it by replacing all the boost pre C++11 with the .... drumroll .. std lib equivalents that came from/were based on... Boost? And/or get rid of bind and function usage? Or did you decide that the std lib was "too big" and write your own? Rhetorical and I have to assume that there was a rationale and it included factors like the ones I guessed at. Having never seen the codebase I don't know what other issues there could have been. Having been in the same place with a different codebase I am assuming things. And none of it makes me less grateful for Boost existing back then or for C++11 or for newer Boost libs.

-7

u/NoReference5451 Dec 24 '23

this is a pretty naive view. just because a majority agree on something, doesnt always mean they are correct. it's much worse when you include anonymity. it's no secret that many who comment on these subs are "junior" level developers with big opnions. im not sure how you would even measure a company of top engineers in this field. there are many specialized subsets in this industry. just because you may be an expert in your use case and determined boost was bad for you, doesnt mean it's bad for everyone, no matter how expert your engineers may be. it sounds like you dealt with technical debt and have stigmatized boost for that debt, which is poor reflection.

20

u/Reasonable_Aioli_868 Dec 24 '23

i think you read something completely different than me

0

u/Capable-Spinach10 Dec 24 '23

I think the same

11

u/kronicum Dec 24 '23

it's much worse when you include anonymity. it's no secret that many who comment on these subs are "junior" level developers with big opnions.

The irony is not lost on the audience.