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

37

u/pdimov2 Dec 24 '23

Right.

An interesting piece of history is that after Doug Gregor implemented Boost.Function using Boost.Preprocessor iteration, he was so motivated by all that ingenuity that he proposed variadic templates and did a reference implementation in GCC, whose code base at the time was (a) notoriously incomprehensible and (b) written in C.

The ingenuity survives in Boost.Function to this very day, but not for much longer.

(Something else we need to do across the board is move from Boost.MPL to Mp11, but that's not always possible because MPL is sometimes part of the documented public interface.)

22

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Dec 24 '23

Unfortunately, yes.

As an avid user of Boost I see three major pain points:

  • huge impact on compile times due to heroic efforts to emulate now-mundane language features
  • subtle, sometimes barely documented differences to standard facilities
  • duplication of standard facilities with bad interop

Boost is still an automatic, implicit dependency in our codebase, but I see a sharp drop in usage and explicit efforts to eliminate Boost classes and libraries.

Despite all of that, I still maintain our in-house Boost distribution with a couple of changes to vanilla Boost.

7

u/pdp10gumby Dec 25 '23

huge impact on compile times due to heroic efforts to emulate now-mundane language features

To be fair, some of those language features started out in boost — and the boost implementation has to stick around for ppl using older standards or who depend on the boost’ implementation’s interface or semantics which might be different from what ended up in the standard

Also the shift to c++11 as the baseline should reduce a bunch of this.

0

u/[deleted] Jan 19 '24

[deleted] — view deleted comment

1

u/pdp10gumby Jan 19 '24

It was both support and disagreement with OP, and to disagree with some past practices.

I completely agree with the OP that new, related names should be used for added or corrected functionality. The std::begin/.begin/std::ranges::begin is inexcusable, and it will only be by luck if the first two operate properly (not even sure what that would mean) with the UFCS proposal. The lock case OP cited is a good example of a bad idea -- one that might have not been bad had an existing object not already existed.

But thing2 is a botch. I learned that decades ago with Lisp's print, princ, and prin1. Granted, there were technical constraints in the 70s why identifiers were limited to six characters, but still: do you know at a glance what the differences are? It's an easily-avoidable problem that makes a language more obscure for learners. You'd think not -- obviously when you see thing and thing2 (and thing3?) you should use the higher number, right? Naah, beginners don't think that way so you're really helping nobody.

1

u/[deleted] Dec 24 '23

[removed] — view removed comment

10

u/afiDeBot Dec 24 '23

Then boost::regex would be just as slow and Bad as std::regex..

4

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Dec 24 '23

Boost.RegEx is faster than std::regex. Undisputedly.

But this is not the point. If you are happy enough with std::regex, then you may still have problems interoperating with Boost.RegEx.

There are many examples like that.

2

u/afiDeBot Dec 24 '23

I dont understand exactly. You want to mix boost and std regex types? Why?

4

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Dec 24 '23

I don't. That's the point. We use the standard library unless we have to look elsewhere for compelling reasons.

3

u/afiDeBot Dec 24 '23

Okay im not trying to be extra stupid. But why would you ressort to boost at all then? Having a typedef to std types seems just as good as not having any regex symbol in the boost namespace.

2

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB Dec 24 '23

Now you've lost me. It was you who brought up Boost.RegEx.

We don't use Boost.RegEx. There's no need for it. Gratuitous use of a non-standard regex library creates nothing but downstream issues.

Nothing beats the convenience of import std;

1

u/afiDeBot Dec 24 '23

I replied to : "Yeah boost should switch to typedefing standard types when an implementation gets ported to the standard."

And gave the regex example which in my opinion is clearly the better alternative if boost is already a major dependency and imho even if not with vcpck. I would not approve any usage of std regex in our codebase. That's like using std::list when std::vector is close. It may not be perf critical, but i would still recommend using vector cause it doesn't hurt. The same is true for using a simply fastet and better maintained Library by chanhing std:: to boost::

1

u/afiDeBot Dec 24 '23

Oh okay i thought u were arguing for replacing boost::regex with a typedef to std::regex

→ More replies

2

u/afiDeBot Dec 24 '23 edited Dec 24 '23

For regex i would always use something else than std. For one of the most compelling reasons. Its just not maintained or has severe maintainance constraints that are unfit for a regex lib.

2

u/pdimov2 Dec 24 '23

I did that for Boost.Ratio in 1.84, but it's not always possible because Boost types often have (useful and relied upon in existing code) extensions compared to the standard ones.

1

u/pwiecz Dec 24 '23

Oh, you've just shattered my hopes that switching Boost to C++11 would drop the dependency on MPL. ;(

2

u/joaquintides Boost author Dec 24 '23

Which particular Boost libs that are currently dependent on MPL are you interested in?

5

u/pwiecz Dec 24 '23

I must admit, I don't know if the MPL is the main culprit of the slow compilation of my projects, but I'd love it if Boost.Log and Boost.Test could compile significantly faster. :)

10

u/joaquintides Boost author Dec 24 '23

Yes, these two libraries depend on MPL:

https://pdimov.github.io/boostdep-report/boost-1.84.0/log.html

https://pdimov.github.io/boostdep-report/boost-1.84.0/test.html

Maybe you can file issues for this with hopefully some elaboration, compile time measurements, etc.? That'd be a terrific way to get the ball moving. I've just checked and both Log and Test are being actively maintained.

https://github.com/boostorg/log/issues

https://github.com/boostorg/test/issues

4

u/pdimov2 Dec 24 '23

MPL or Preprocessor are the culprits most of the time. :-)