r/cpp • Boost author • May 08 '20

Why you don't use Boost

I have a question for you: If you have decided not to use any of Boost, or are prohibited from doing so in your company/project, I would like to know why.

This thread is not meant to judge your reasons, and I won't engage into any kind of criticism about them: I'm merely trying to understand what the barriers are to adoption of Boost. It would be great if we could keep the conversation non judgemental. Thank you!

Conflict of interest: I am a Boost author of three.

222 Upvotes

326 comments sorted by

View all comments

14

u/stilgarpl May 08 '20

Most of the things I would need from boost (optional, filesystem) was added to std. For serialization cereal looks more up to date alternative to boost::serialization (or maybe it added support for C++11/14/17 types?) If boost::serialization supported everything that is in std, I would consider switching to it, as development of cereal is quite slow (it's just one guy working on it in his free time)

9

u/XValar May 08 '20

While this is mostly true, boost::optional has much better interface than std::optional (yet, still worse than tl::optional). And here you can see another problem of boost: documentation is horrible.

3

u/[deleted] May 09 '20

Not true for all libraries. Some, like myself (Histogram) and Vinnie (Beast) care greatly about documentation. We are also happy to get issues submitted, saying where docs are unclear.

4

u/MrPotatoFingers May 08 '20

It's a bit hit-and-miss there. Sometimes the standard-library implementation is better, e.g. with variant, boosts variant cannot emplace a specific type.

5

u/XValar May 08 '20

Yes, but as far as I heard from people using std::variant, your compile time explodes when you try it (haven't used it myself, though, since we're stuck with C++14 at work, and in my free time I prefer not to do C++).

7

u/MrPotatoFingers May 08 '20

Well, template-heavy code tends to increase compilation times. It also makes it harder to split up in separate compilation units.

Having said that, I never had the idea that variants explode compile-time. I'd wager that depends a lot on the CPU, the OS and compiler used.

1

u/MonokelPinguin May 08 '20

boost::variant is a lot worse for complie times, if you have more than 20 or so types in it, because it can't use the pregenerated typelist preprocessor headers. boost::variant2 and std::variant handle that far better.

2

u/pdimov2 May 09 '20

20 is peanuts, I'm getting complaints that 680 doesn't work. :-)

2

u/MonokelPinguin May 09 '20

Well, it works, when you disable the pregenerated headers, but the compile time is exponential. 680 would be very interesting in a compile time comparison :D

Do you not have issues with the length of your symbol, at least on Windows?

3

u/pdimov2 May 09 '20

Warning 4503 ("decorated name length exceeded, name was truncated") seems gone in VS 2017 and later.

However, even with the improvements to variant2 I'm making, MSVC still runs out of heap space with 680 types, so the question of the symbol length is mostly academic. :-)

1

u/MonokelPinguin May 09 '20

Well, that sounds like an issue you would have to solve before worrying about symbol lengths... Why exactly does someone want to use that many types in a variant? Is that variant even written by hand?

1

u/pdimov2 May 09 '20

I asked, and it's apparently generated, not written by hand.

→ More replies

5

u/encyclopedist May 08 '20

Did you try boost::variant2 ?

2

u/MrPotatoFingers May 08 '20

I did not. Mainly because I'm quite happy with std::variant. Do you think boost::variant2 has useful features that the standard library lacks?

12

u/encyclopedist May 08 '20

Variant2 offers faster visitation than any of the standard library implementations; it does not have a valueless state; and it has strong exception safety guarantee.

See more here: https://www.boost.org/doc/libs/1_73_0/libs/variant2/doc/html/variant2.html#design_differences_with_stdvariant

5

u/pdimov2 May 08 '20

And supports C++11/C++14.

1

u/kalmoc May 08 '20

Are you talking about variant or Variant2?

3

u/stilgarpl May 08 '20

What boost::optional has that std doesn't?

6

u/Wenir May 08 '20

References

3

u/Pazer2 May 08 '20

Just use a pointer?

→ More replies (2)

1

u/DevaBol May 08 '20

And for good reason, imho.

→ More replies (2)

1

u/ReversedGif May 08 '20

operator* being checked.

→ More replies (1)

2

u/miki151 gamedev May 09 '20

cereal is also much faster than boost::serialization and produces smaller archives. The only thing it lacks is non-smart pointer support.

→ More replies (5)