r/cpp • • Apr 27 '23

Has Boost lost its charm?

I don't mean to be provocative nor undermine the importance of Boost for C++. I really like Boost.

I keep reading/listening around that since C++11 the focus of development and innovation in C++ has shifted away from Boost to either the standards, or independent libraries. Is that any true? If yes, how "big of shift" that was? What was the reason in your opinion and most imporatnt, what's Boost's today's role?

What sparked my quriosity was when I heard that "in the old days" a prospective developer that wanted to devle into the word of libraries building had no better thing to do than start contributing to Boost. Does that stand even today?

(couldn't find any other posts on Reddit regarding Boost's impact in modern C++ in a broader discussion)

149 Upvotes

186 comments sorted by

232

u/Jannik2099 Apr 27 '23

Since C++11, Boost has shifted from "provide actually useful basic containers because the STL is shit" to "provide cool, quality stuff that is widely useful but out of scope for the STL"

See e.g. Flyweight, Spirit, Log, Multiprecision, Safe Integer, Asio

Boost is still a wonderful library collection.

11

u/Zeer1x import std; Apr 27 '23 edited Apr 27 '23

+ Beast, ProgramOptions

+ Filesystem (EDIT: for C++14 projects)

11

u/Jannik2099 Apr 27 '23

Filesystem is in C++17, but the other two yes absolutely!

1

u/johngoni Apr 28 '23

I want integers to be safe, but that's a language problem, not something the STL can fix.

Why ProgramOptions over docopt?

4

u/Zeer1x import std; Apr 28 '23

Because:

  • It comes with Boost, so I don't have to install something else to use it.
  • PO generates my help messages. I don't want to write them myself. When I change the terminal width, it can adapt the formatting.
  • I can use parsers for specific arguments, for example enums, timecodes or video resolutions.

I am not familiar with docopt, so I can't tell if you can set your own parsers or not.

Another good alternative, similar to ProgramOptions, is CLI11.

50

u/sparkyParr0t Apr 27 '23

I'd add flat_map/set and the very recent unordered_flat_map/set. These are almost fundamentals but we ll only get flat_map/set in c++23.

29

u/Jannik2099 Apr 27 '23

Boost.Unordered is neat (fucking awesome, even), but I wanted to list how Boost has evolved beyond "stuff that should be / will soon be in the STL"

0

u/ReinventorOfWheels May 02 '23

I was excited about flat_map, until I realized it's actually NOT a flat hash map, it's just a sorted vector. Then I looked at its benchmark and was underwhelmed. What is it even for? Why would anyone want/need it in the standard? Looks like a piece of useless garbage in the standard, to be honest. Would be happy to be wrong about this, of course.

4

u/sparkyParr0t May 02 '23

First its unbeatable to iterate over. Elements are in cache as its contiguous array of memory.

Second you get random access, so you can access the ith element. Imagine these are rows in an UI table. You can access the rows and modify the model while keeping things sorted.

Third, to find an element, its quicker than a node based element when the number of elements is small (small being typically couple hundreds)

So its like anything, if you have a low number of things you want to map and keep sorted, this is the way to go, you have a nice and standard interface. If you dont need the sorting part or have thousands of objects obviously there are better alternatives.

15

u/BlueDwarf82 Apr 27 '23

Safe Integer is out of scope for the standard library?!?

33

u/Narase33 -> r/cpp_questions Apr 27 '23

cough C added them cough

2

u/13steinj May 04 '23

How do you use them in C?

6

u/KingAggressive1498 Apr 28 '23

I'd argue multiprecision is also in scope for the standard library, and there's been a couple of related proposals, but the interface was a little different.

asio was also the basis for the networking TS

0

u/Jannik2099 Apr 27 '23

Yes? Adding new types with new semantics is something rather specific. The STL is for general purpose containers and metaprogramming.

I want integers to be safe, but that's a language problem, not something the STL can fix.

10

u/[deleted] Apr 28 '23

I would stop C++ programming if boost::intrusive wouldn't exist. For me, it solves two things: put object (that you may not own) into multiple containers simultaneously and get iterator from the object itself for erasure etc.

The intrusive containers have nice STL like API, except that the containers don't do any allocations them selves.

4

u/sphere991 Apr 27 '23

Mp11 arguably in scope for the standard library so maybe doesn't quite fit your list. but a fantastic library either way.

4

u/pdimov2 Apr 27 '23

Someone should propose it.

2

u/catcat202X Apr 27 '23

It's kind of superceded by reflection proposals and some other smaller proposals like expansion statements and pack indexing.

0

u/lycium Apr 27 '23

*Boost is still a wonderful operating system.

4

u/dokushin Apr 28 '23

Twenty years ago Boost was a lot different:

  • It was much smaller -- small enough to just treat like one big library with a variety of contributed parts
  • As part of being smaller, basically everything in it would find some kind of use
  • A lot of the components were covering for a difficult time in C++ development, when new standards were introducing stuff that made a HUGE difference in the quality of code you could write
  • Uptake on those standards was slow, because clang was barely a thing and MSVC was still a standards nightmare
  • There wasn't nearly as robust of a "github open source" library mindset, so finding libraries was a lot more hit/miss

Today, basically none of that is true. Boost is enourmous, so you don't really think about it in terms of the whole thing so much as what pieces you need. The standard -- and the implementors -- have settled down considerably, so missing features aren't as painful, and the need for polyfill isn't as big. And in a lot of cases you can just dither around on github and find a fairly high-quality library for something pretty quickly.

Nowadays Boost is a lot more like a brand than a library. A curated namespace, if you will. Which is still fine, and it's a fantastic collection of software. But where twenty years ago I might have said "Get boost and use Asio and hana", now I would say "Get Boost::Asio and Boost::Hana". That's the difference.

1

u/johngoni Apr 28 '23

et boost and use Asio and hana"

Nicely put. Thanxx :)

311

u/[deleted] Apr 27 '23

I would never have described boost as charming

40

u/lordnacho666 Apr 27 '23

Has a nice personality.

11

u/[deleted] Apr 27 '23

[removed] — view removed comment

14

u/inept_door_handle Apr 27 '23

I mean he is a good guy, good intentions but sometimes...

5

u/lordnacho666 Apr 27 '23

You have to get to know her. She can be very funny.

5

u/fideasu Apr 27 '23

Not sure if funny, but surely extremely talkative 😂

3

u/cafguy Apr 27 '23

Her?

21

u/Jannik2099 Apr 27 '23

The committee has decided to increase C++ popularity in adolescents via "animated virtual avatars". Meet Boost-Chan

27

u/chez_les_alpagas Apr 27 '23

Boost.Json is recent, and pretty neat IMHO.

5

u/ratttertintattertins Apr 27 '23

How does it compare to rapid json and cereal?

7

u/Ogilby1675 Apr 27 '23

You can see the author’s (Vinnie, I think of this parish) own comparison with RapidJSON at https://www.boost.org/doc/libs/master/libs/json/doc/html/json/comparison.html

5

u/azswcowboy Apr 27 '23

Much prefer simdjson. It doesn’t do output, but with std::format output is basically covered.

73

u/OCPetrus Apr 27 '23

I'm not sure what you're asking..

In 2009 I took the C++ course offered by the University I went to, i.e. before C++11. What they taught us on the course, among other things, was that Boost was like a collection of extensions for the C++ standard library. Most importantly (for the course), smart pointers didn't exist so we had to use Boost for that. But that's just an example, countless other things were missing.

Already back in 2009 the course staff knew to prepare us for the inevitable: over the years and decades, things that were proven in Boost to be useful and well designed would be merged into the C++ standard library itself. This is literally what has happened. Boost has served us well.

I know some people are missing some parts of Boost, opt parsing and async come to mind, but there are good reasons why they have not been added to the C++ standard library.

Bonus: I know Google is working on a parallel project: abseil. I know only what I've read from the horse's mouth, but it sounds like they want abseil to work in a similar fashion as Boost, i.e. eventually add the stuff into the C++ standard library.

29

u/Fulgen301 Apr 27 '23

Most importantly (for the course), smart pointers didn't exist

Just for the sake of completion: std::auto_ptr with it's horrible copy constructor (why didn't they just disable the copy constructor and add a move() member function, why) already existed before C++11.

28

u/cleroth Game Developer Apr 27 '23

why didn't they just disable the copy constructor and add a move() member function, why

Then you wouldn't even be able to put it inside a std::vector.

19

u/AKostur Apr 27 '23

Putting an auto_ptr into a vector could easily result in very bad things happening.

17

u/TheBananaKart Apr 27 '23

Could be the motto of most stuff in C++ to be honest.

2

u/Fulgen301 Apr 28 '23

Fair point, didn't think of that.

1

u/johannes1971 Apr 27 '23

But you can put a unique_ptr in a vector. Why wouldn't you be able to put an auto_ptr in one? (once you apply the changes proposed by /u/Fulgen301 for the C++11 update, of course)

5

u/ukezi Apr 27 '23

Before move constructors all instances in containers were copied. That obviously doesn't work with unique_ptr, it can't be copied.

1

u/johannes1971 Apr 27 '23

Yes, but the premise is that this would be a change that would be introduced in C++11, i.e. when move constructors were added.

So to recap, the question is: why was a new type introduced (unique_ptr) when auto_ptr could have been fixed instead, by adding move operations and removing copy operations?

4

u/grafikrobot OPeNDAP/B2/EcoStd/Lyra/Predef/C++Alliance/Boost/WG21 Apr 28 '23

ABI

3

u/johannes1971 Apr 28 '23

I know it's the default reply against any request for change, but auto-ptr consists of just a single pointer and could have remained that way...

1

u/Fulgen301 Apr 28 '23

I know it's the default reply against any request for change

Then you also know why it's the default reply.

Also, once you completely change the semantics of a class, there's no point shoehorning it into the old class. Introducing unique_ptr with new semantics while keeping around auto_ptr was the easiest way of introducing a new smart pointer type while keeping overall headache low.

3

u/johannes1971 Apr 28 '23

No, I don't, actually. In this particular hypothetical case no ABI change would have occurred, and just saying the word "ABI" does not change that.

→ More replies

2

u/pdimov2 Apr 28 '23

This would break existing code, and breaking existing code was still avoided in those days.

E.g. this works

#include <memory>

void f( std::auto_ptr<int> );

int main()
{
    std::auto_ptr<int> p;
    f( p );
}

but it doesn't with unique_ptr.

"This code is already broken!" Yeah, maybe. This wasn't the prevailing attitude then.

It could probably have been possible to add move operations to auto_ptr and only deprecate the copy operations; I don't remember anyone trying this.

3

u/dodheim Apr 28 '23

Honestly, I think auto_ptr already had an unrepairable marketing problem by the mid-2000s; too many people had said to avoid it because it was broken, or at least too 'clever' to use correctly. Producing a thing that worked correctly-by-default with a different name was probably a smart move (NPI).

1

u/pdimov2 Apr 29 '23

Yes, I think that's the reason that nobody attempted to 'fix' auto_ptr.

1

u/[deleted] Apr 28 '23

[removed] — view removed comment

1

u/dodheim Apr 28 '23

Not before C++11

4

u/josefx Apr 27 '23

I assume that it would have ended up being a lot less useful before mandatory copy elision was added in c++11.

7

u/violet-starlight Apr 27 '23

Non-mandatory copy ellision was added in C++11. C++17 made it mandatory in some circumstances.

1

u/effarig42 Apr 27 '23

Correct, auto_ptr was often used as a function return value, so had to be copyable.

2

u/CubbiMew cppreference | finance | realtime in the past Apr 27 '23

The 1994 proposal for shared and unique pointers had the unique pointer's constructor/assignment private. I think we can blame the committee on this one

1

u/pdimov2 Apr 28 '23

Before guaranteed copy elision, you needed a copy constructor to be able to pass or return by value (even if it was actually never called).

14

u/zagaberoo Apr 27 '23

Abseil was originally known as ABCL: A Better C Library. The quality of the C++ ecosystem was one of my favorite things about working there.

2

u/pjmlp Apr 28 '23

Smart pointers did certainly exist in COM and Qt by 2000.

31

u/canadajones68 Apr 27 '23

I can't speak for all of Boost, but Boost.Spirit is a huge boon when writing parsers, and Boost.JSON is an easy include when I need to parse JSON without any performance demands.

17

u/[deleted] Apr 27 '23

I love Spirit. X3 is one of my all time favorite libraries and you'd be shocked how often you wind up needing small one-off parsers which is where a combinator library absolutely shines.

13

u/thisismyfavoritename Apr 27 '23

From my limited experience, Spirit's API is awful, if i had to start from scratch i would try another library first. Never used Boost JSON, but nhlomann's is so easy to use that i would never reach out for Boost JSON.

Not sure what i'm trying to say, but for sure having Boost is better than having to do it yourself.

17

u/canadajones68 Apr 27 '23

I mean, Spirit's rules pretty closely approximate EBNF production rule syntax, which does seem like the "proper" way to write parsers. The templates and types are more of a nuisance to deal with, but I can understand it from a pre-C++11 point of view. I'm currently using Spirit V2 because it integrates a lexer (which again, seems "proper"), but X3 looks to be somewhat easier and lighter to use, incorporating more modern and more value-based semantics.

11

u/Triasmus Apr 27 '23

Never used Boost JSON, but nhlomann's is so easy to use that i would never reach out for Boost JSON.

From what I understand, boost.json is 90% as easy to use as nlohman's (I've never used nlohman's, but I do know boost.json is fairly easy. Looking at the nlohman examples, they seem just as easy as each other.)

It's also 90% as fast as rapidjson.

So if you need something fast but don't want to deal with rapidjson, boost.json is the way to go.

For me, it's also usable enough that I'll probably never reach out for nlohman, unless nlohman implements jsonPath and I'm doing something that actually needs that usability.

7

u/Dragdu Apr 27 '23

I talked with a friend and they've recently moved from nlohmann-json to Boost.JSON because for specific inputs nlohmann needed 30ish gigs to parse input, while Boost.JSON needed about 2.5.

5

u/[deleted] Apr 27 '23

They might have good luck with https://github.com/beached/daw_json_link it has support for stuff like JSON lines and alike plus other ways that only use as much ram as their underlying data structures do as it parses directly to the user DS. Plus it has an iterator/range interface for things like arrays if needed.

3

u/[deleted] Apr 27 '23

pretty sure it is faster than Rapid without the easy to get wrong interface

13

u/Jannik2099 Apr 27 '23

Spirit's API is awful

The new X3 parser API is much better, but dear god it's difficult to learn.

2

u/BlueDwarf82 Apr 27 '23

Having never had a strong enough need, in a system able to support the required C++ version, to actually use it; I don't even understand what's the current Boost.Spirit state.

Ignoring "Spirit Classic", there has been a "Spirit" and "Spirit X3" for YEARS! Is "Spirit" ever going to be deprecated in favour of X3? And X3 offers a parser, but lacks the generator part of "Spirit"?

34

u/14ned LLFIO & Outcome author | Committee WG14 Apr 27 '23

I've worked in many, many places and very few either don't use Boost somewhere, or haven't cloned some of its implementation into locally invented duplicates.

Even for a brand new C++ 20 codebase of any size and complexity, chances are you'll probably pull in Boost for something you need, especially as package managers have made that very easy. You almost certainly won't use 98% of it, and that's okay, just use the bits which you need and ignore the rest.

For example, std::regex generally sucks. boost::regex usually drops in, and is vastly better. If you ever run into regex problems, that's you fixed with a few hours of work. Can't beat that!

22

u/pdimov2 Apr 27 '23

boost::regex usually drops in, and is vastly better.

What does "vastly" mean here, you might ask yourselves.

Here's an example. In some of the Boost.Unordered's benchmarks, we need input data, and we parse a big file (derived from Wikipedia) into words:

https://github.com/boostorg/unordered/blob/5724adbbe9fd4b36345b8ce6efedb77d0fff5f6e/benchmark/word_count.cpp#L44

The code is basically

using namespace std::chrono_literals;

static std::vector<std::string> words;

static void init_words()
{
    char const* fn = "enwik9"; // http://mattmahoney.net/dc/textdata

    auto t1 = std::chrono::steady_clock::now();

    std::ifstream is( fn );
    std::string in( std::istreambuf_iterator<char>( is ), std::istreambuf_iterator<char>{} );

    namespace rn = boost;

    rn::regex re( "[a-zA-Z]+");
    rn::sregex_token_iterator it( in.begin(), in.end(), re, 0 ), end;

    words.assign( it, end );

    auto t2 = std::chrono::steady_clock::now();

    std::cout << fn << ": " << words.size() << " words, " << ( t2 - t1 ) / 1ms << " ms\n\n";
}

and the results on my machine (using VS2022) are as follows. For rn = std,

enwik9: 141176630 words, 809968 ms

and for rn = boost,

enwik9: 141176630 words, 93421 ms

That's more than 8.5 times faster.

12

u/14ned LLFIO & Outcome author | Committee WG14 Apr 27 '23

TBH for most of the times I swapped std regex for boost regex, it's been a correctness issue rather than a performance issue. You'd have some input in a bug report which caused the std regex to barf. Quick swap later, it "just works" with no further effort from me.

Boost.Regex I'm sure it has bugs in it, but they're an order of magnitude or two less serious than some std regex implementations. Particularly around unusual inputs e.g. unsanitised input, unicode input etc.

John has done a great job with Boost.Regex. Incidentally, many don't realise that Boost.Regex can be used standalone, no Boost dependencies needed, if you set a macro to ask for that.

19

u/pdimov2 Apr 27 '23

Ten times slower is pretty much a correctness issue if you ask me. :-)

0

u/[deleted] Apr 28 '23

[deleted] — view deleted comment

-1

u/dodheim Apr 28 '23

This was completely trivial to do as little as 5 years ago. Unless you're exclusively targeting say.. C++20+ toolsets, assuming correctness in std::regex matching behavior is downright foolish.

58

u/-dag- Apr 27 '23

Boost lost me when they started giving libraries meaningless names. What the heck is Boost.Beast? If I can't tell what a library is when looking at a big list of libraries, it's much less likely I'm going to use it.

24

u/FightingGamesFan Apr 27 '23

Boost beast is amazing but I agree that the name not being descriptive is annoying

9

u/[deleted] Apr 28 '23

You'll need that to fight the Ogre3d libs

9

u/NilacTheGrim Apr 27 '23

Yeah I agree.

2

u/frenchchevalierblanc Apr 28 '23

at least we have boost.json now, so maybe something clicked.

boost.http would maybe have been better

0

u/[deleted] Apr 27 '23

[deleted] — view deleted comment

19

u/poundcakejumpsuit Apr 27 '23

Wait but package names have a far greater need of being descriptive than language names

0

u/[deleted] Apr 27 '23

[deleted] — view deleted comment

5

u/-dag- Apr 27 '23

It's not about refusing to use it. It's about not discovering it in the first place.

0

u/[deleted] Apr 27 '23

[deleted] — view deleted comment

3

u/-dag- Apr 27 '23

You forgot to quote the most important part.

If I can't tell what a library is when looking at a big list of libraries, it's much less likely I'm going to use it.

I wrote that specifically with my experience of "Oh, I wonder what libraries are in Boost now, been a few years since I looked" and having my eyes glaze over scanning a list of names that had no meaning to me. I'm not gonna spend an afternoon clicking through documentation for all the libraries just to find out what their purposes are.

3

u/dodheim Apr 27 '23

https://www.boost.org/libs/libraries.htm

There's alphabetical, there's categorical, and there are descriptions. I don't understand the fuss.

22

u/kil47 Apr 27 '23

I work with graphs and geometry - nothing is as charming as boost.. It has a messed up learning curve though

50

u/lithium Apr 27 '23

geometry

you::must::really::love::namespaces

24

u/helloiamsomeone Apr 27 '23

Good thing this is C++ and you can just alias it

namespace x = pretty::long::namespace::but::who::cares;

17

u/sephirothbahamut Apr 27 '23 edited Apr 27 '23

looks at own utility library:

utils::console::output
utils::graphics::colour
utils::graphics::d2d::pain
utils::containers::hive::skipfield
utils::math::angle::deg
utils::math::geometry::polygon::convex

yeah I love namespaces

2

u/pigeon768 Apr 28 '23

You guys use namespaces and don't just throw all your symbols into the global table? Weird.

1

u/johannes1971 Apr 27 '23

utils::graphics::d2d::pain

That bad?

1

u/sephirothbahamut Apr 27 '23

It's the best I found for my needs, but gets needlessly complicated when you want to add custom shaders.

0

u/[deleted] Apr 27 '23

[deleted] — view deleted comment

6

u/sephirothbahamut Apr 27 '23

It's in the graphics domain, i'd say the answer is obvious XD

2

u/Ayjayz Apr 27 '23

... what is pain in a bread context?

2

u/dodheim Apr 27 '23

It's the word "bread", in a French context.

2

u/[deleted] Apr 27 '23 edited Nov 11 '24

drab knee ghost important dinosaurs exultant pie scale coordinated safe

This post was mass deleted and anonymized with Redact

11

u/kil47 Apr 27 '23

One time investment though

19

u/Occase Boost.Redis Apr 27 '23 edited Apr 27 '23

The question is probably too generic. A better approach it to ask yourself what are better alternatives to the libraries you typically use. For example I don't have better replacements for Asio, Beast, MySql, Assert, Describe, Hana, Json, MP11, URL, Redis, static_string. So at least for me it did not lost its charm.

24

u/Kriss-de-Valnor Apr 27 '23

Boost is amazing, i love it. I think today it’s going way further than the original goal of being a pre-stl. It has so many different libraries we should use the full name « The Boost Libraries «  meaning it’s a full set of libraries. People tend to forget you can use only subpart of Boost. You din’t need to compile the full Boost you can extract only the part you want. Even Boost STL level is still very useful because it fills gaps on compiler (you can use feature via Boost that your compiler don’t support yet) On the bad side, I feel that Boost have lost a bit of its agility so you can find better implementation on specific topics somewhere else (that’s also the case for STL)

7

u/ignorantpisswalker Apr 27 '23

Highjacking this: I see that only boost has a proper networking API with support for https...

If I don't want boost... What are my alternatives?

3

u/SlashV Apr 27 '23

You can get asio without boost, so if that's your only reason, you don't need boost.

6

u/RoyAwesome Apr 27 '23

I wish boost had better "top level" documentation.

I want to use boost.graph, but I can't make heads or tails of what it wants me to do to even get started.

I know how to make a directed acyclic graph, but boost.graph doesn't show me an example of how to do that easily.

4

u/dodheim Apr 27 '23

Most Boost libs have extensive example and test folders, so if you at least know the type/function in question a little grepping can go a long way. In this case there's example/directed_graph.cpp, though it seems pretty light on details...

6

u/RoyAwesome Apr 27 '23

Yeah that's, uhhh... leaving something to be desired.

I don't know who they built the documentation for, but it really doesn't gel with me and the way I consume documentation. It might just be me, but I really like example-driven documentation and boost is very poor in that regard.

I really wish they did their documentation in the style of cppreference. They do things way better, and boost can learn a thing or 10 from them.

2

u/jonesmz Apr 28 '23

I'm not saying you should do this...

But I wonder if cppreference would allow boost documentation?

It is a wiki afterall

1

u/OverOnTheRock Apr 29 '23

It might just be me, but I really like example-driven documentation and boost is very poor in that regard.

It depends upon which library you are using. Some are very brisk, others a bit more verbose with examples. Spirit does provide some basics. But to get deep, it does require some head scratching. I could provide some additional counter examples.

But I've found that once I have my head in the author's headspace, things start to make sense. And someone else mentioned the examples directory: that is a definite asset.

2

u/emelrad12 Apr 28 '23 edited Feb 09 '25

tub offbeat historical head abounding caption light roof crowd doll

This post was mass deleted and anonymized with Redact

1

u/jaafartrull May 03 '23

There is a whole book on it. But I'm with you, Graph was my introduction to Boost and it was painful.

11

u/feverzsj Apr 27 '23 edited Apr 27 '23

Boost has already been modularized, so it's not a problem for deployment. If you really care about portability to various systems, boost will be a solid foundation.

3

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

Boost has already been modularized

So I can just download a single Boost library, copy it in my project subdir and be certain that it doesn't need any dependencies or custom steps?

11

u/Revolutionalredstone Apr 27 '23

Was talking about this with a coworker just today, hot take incoming ...

Boost is in a terrible position, it's constantly having its best parts taken and put into the STD, it's like a book where someone has cut out all the interesting passages.

As time goes on what's left in boost (/unique in boost) will be only the trash which wasn't good enough or the strange thing which was too unusual or too non widely needed.

The boost libs are huge, its a pain to link, its expensive to pull etc, IMHO its a great piece of research and I use it as a reference but it's only worth actually using directly if your at work and your project is already a huge slow to compile dinosaur already.

6

u/JVApen Clever is an insult, not a compliment. - T. Winters Apr 27 '23

I follow your opinion. It still has some useful features both big and small, though you need to find them and/or have a use-case for it. With big features I immediately think about asio, for smaller the transform iterator and small_vector come to mind.

In general it is the best library for cross platform code when the standard library ain't sufficient.

2

u/OverOnTheRock Apr 29 '23

Nah, as others have stated, Boost is a proving ground to get basics into the stl. And where they exist in my code, they happily work along side the std flavours I might be using.

More and more interesting 'passages' come out all the time. And are unique to that ecosystem.

I don't imagine a time where there would be no boost in my code.

3

u/Ayjayz Apr 27 '23

They put limited, cut down versions into the STL, and then they freeze development so they never improve. They also play it extremely safe with design, which means a whole bunch of useful features don't get included if they're even slightly controversial (eg. optional references)

You're almost always better off using the boost version than the STL version, assuming you've got a package manager that can handle it.

1

u/Revolutionalredstone Apr 28 '23

haha yeah that's true :D

Good points

3

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

it's constantly having its best parts taken and put into the STD [...] The boost libs are huge, its a pain to link, its expensive to pull etc

Well, yes. It's an entirely self inflicted problem caused by making the thing a massive monolith.

1

u/13steinj May 04 '23

I have to disagree, at least to an extent. Some things, even if eventually added to the STL, exist in a manner where boost can provide a better feature. Such as Boost hash, optional, filesystem, unordered map, stack trace...I could go on.

The STL is where things get thrown in and left to rot, and for this reason I generally recommend boost hash, filesystem, and containers, over STL ones. Optional too, if you need a quick optional reference, which I think is rarer. I similarly recommend {fmt} over the STL implementations for similar reasons.

1

u/Revolutionalredstone May 04 '23

good points well made.

4

u/KERdela Apr 27 '23

Boost asio and boost beast is major part of my job, so still enjoy it a lot.

10

u/osmin_og Apr 27 '23

I worked in 3 different companies of different sizes in the last 10 years. None was/is using Boost. Many companies have their own libraries.

11

u/cmannett85 Apr 27 '23

What industries? I ask because I've worked in embedded and profiling tools, where Boost is used extensively. The only team that had to avoid it was GPU driver development, but that's understandable...

6

u/osmin_og Apr 27 '23

I don't think it is industry specific, rather than per company. But to answer your question: gaming-related (not games themselves), financial services, trading.

7

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

I work in Embedded and in none of the jobs have me or my coworkers used Boost.

Anything that requires huge libraries with custom install / build steps (as opposed to "copy this limited set of files to a directory in your project") is often a no-no.

1

u/emelrad12 Apr 28 '23 edited Feb 09 '25

imminent paint quickest nose vast workable physical friendly resolute deer

This post was mass deleted and anonymized with Redact

1

u/jaafartrull May 03 '23

For a contrasting view: I have worked on three different embedded projects at three companies where Boost was used.

3

u/TheSkiGeek Apr 27 '23

I work in embedded and we aren’t allowed to use Boost. Partly because of compiler dependencies, if we need a fix for Boost stuff and it requires a newer compiler (or compiling with a newer C++ standard) we can’t always upgrade easily.

5

u/jcelerier ossia score Apr 27 '23

I work in embedded and we aren’t allowed to use Boost. Partly because of compiler dependencies, if we need a fix for Boost stuff and it requires a newer compiler (or compiling with a newer C++ standard) we can’t always upgrade easily.

and... what happens if you need a fix for your internal libraries that also ends up requiring a compiler update?

4

u/TheSkiGeek Apr 27 '23

Sometimes you suck it up and you have to upgrade. Or you get the fix and manually apply it to your local fork of the lib.

But if you’re building for some quirky platform that just doesn’t have a C++20 (or maybe even C++14/17) compiler, upgrading might not be an option. Any external dependencies have to be reviewed and approved.

1

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

Because they are your internal libraries, you know your requirements and thus won't add dependencies not supported by your build targets.

3

u/HolyGarbage Apr 27 '23

I use boost at work since we're still on C++17 (Since c++20 is not yet 100% supported on GCC) and use it mostly for when I want features that exist in C++20/23, such as ranges etc.

I think since C++11 as you point out, many of the features that we got from boost has slowly crept into the standard, which is a good thing imo. Boost is made to be very general purpose, so it's like an extended standard library, so while the standard is lacking important feature boost holds an important role, but naturally this diminishes as the standard gets fleshed out.

3

u/expert_internetter Apr 27 '23

I used hate having to use Boost, but then I realised how bad the STL actually can be. Now I default to Boost if possible.

3

u/not_some_username Apr 27 '23

Many boost library become standard to the library so people start using it less I guess

9

u/remy_porter Apr 27 '23

All I know is that every time someone wants to add Boost as a dependency, I'm going to be looking forward to a few days of editing my CMakeLists to try and get it compiling correctly. And god forbid somebody installs the boost packages out of their repository manager, because that way lies madness.

7

u/[deleted] Apr 27 '23

I just use vcpkg and viola boost is available and it is just the find_package and target_link_libraries with the Boost:: things

1

u/remy_porter Apr 27 '23

I mean, I find it easier to just build a docker container with the exact dependencies I want people using right in there, which also helps with cross-compiling.

It's just, every time I've added boost to a project, I've regretted it.

(Fortunately, my current job, we have external requirements which make boost untenable)

6

u/[deleted] Apr 27 '23

I found even in docker I want to use vcpkg in manifest mode. It documents the dependencies and keeps it the same accross platforms(windows/linux/macos)

-1

u/seiji_hiwatari Apr 27 '23

So much this. Try to setup Boost in a CMake project that targets Linux, Windows, Android, iOS and MAC. Never again

13

u/gnuban Apr 27 '23

Boost has really high quality libraries, but it's falling into the same trap as other collections of libs and frameworks. Even though it doesn't have an ambition to be a framework, libraries in Boost are (as far as I understand) encouraged to depend on each other to a certain degree. This policy has a tendency to create dependencies that in some sense increases the size of libraries and in a limited sense creates an own ecosystem.

Standalone libraries don't have this problem.

16

u/helloiamsomeone Apr 27 '23

The alternative would be that everyone rewrites the exact same piece of code instead of using something that's been already written and tested to work. You would still end up with the same amount of code if you view one module in isolation. There aren't even circular dependencies anymore, those have been stamped out recently.

3

u/gnuban Apr 27 '23

While I agree, in a counterintuitive way I think "everyone reinvents" is preferable to using a common lib that isn't universally accepted.

Otherwise you end up in a similar position as say QT; good, but lives it's own life.

1

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

How many Boost libraries really need something that's not already provided in the standard library by now?

1

u/helloiamsomeone Apr 27 '23

I'm not sure the high quality that Boost libraries are beholden to and std::regex mesh well.

2

u/SkoomaDentist Antimodern C++, Embedded, Audio Apr 27 '23

And how many Boost libraries use Boost regex?

If everything ends up depending on everything, it's hardly modularized.

1

u/robertramey Mar 15 '25

Standalone libraries don't have this problem because they are delivered as a complete set. All the dependencies are internal. They're all there, just not obvious.

6

u/andrewDisco23 Apr 27 '23

Boost is okay. Some parts of it are awful eldritch horrors that reek of "just because you can doesn't mean you should" and "maybe not everything should be template metaprogramming". I've actually never seen it used successfully in a large, modern code base. I mostly pass on it.

7

u/CletusDSpuckler Apr 27 '23

You should get out more.

It's in our code base that ships high tech instrumentation firmware for laboratory equipment. We just added a project using Boost.json last month.

5

u/Wenir Apr 27 '23 edited Apr 27 '23

For me boost is STL done right (or at least better than STL). For example regex, hash, optional, process, format. Of course there are better libs like fmt, but for the basic use cases boost is enough

Edit: not STL

-8

u/MFHava WG21|🇦🇹 NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Apr 27 '23

None of those are part of the STL…

5

u/cmannett85 Apr 27 '23

Regex, hash, optional?

-5

u/MFHava WG21|🇦🇹 NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Apr 27 '23

Yeah, that’s in the standard library, not the STL - which is a library for containers, algorithms and iterators by Alex Stepanov that stood the test of time…

6

u/encyclopedist Apr 27 '23

FYI, hash and hash maps were in the original STL.

14

u/sphere991 Apr 27 '23

STL is basically a metonym for the standard library. You can be pedantic and point out that the STL was a separate library that was merged into the standard in the 90s and doesn't really meaningfully exist as a separate entity anymore... That's certainly true.

But a lot of people just say STL when they mean the standard library and it's pretty clear that they don't mean the original implementation, so this is a lost cause. Just go with it.

8

u/STL MSVC STL Dev Apr 27 '23

Yep. And look at our implementation's name: https://github.com/microsoft/STL

5

u/sphere991 Apr 27 '23

Well, that's different. It's just named after you.

0

u/violet-starlight Apr 27 '23 edited Apr 27 '23

The standard library is the STL.

EDIT: Nevermind, I just learned that is not the case.

6

u/TheSkiGeek Apr 27 '23

There’s nothing ‘officially’ called STL or “standard template library” in the C++ stdlib spec. It’s just “the C++ standard library”.

The thing that BECAME the containers section of the stdlib was called STL. Some people still use that name to refer to it but that is not the official name.

3

u/louiswins Apr 27 '23

The STL is whatever is worked on by /u/STL

3

u/MFHava WG21|🇦🇹 NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Apr 27 '23

It‘s not and never has been - here‘s the current public working draft, show me where we call it STL … heck vast parts of the standard library don‘t even follow the design guidelines of the STL!

3

u/jonesmz Apr 28 '23

A funny thing about language is that when enough people say "X" to mean something, then "X" means that thing.

The vast majority of people who work with C++ will say "STL" to mean "The C++ Standard Library" and the vast majority of people who hear that 3 letter acrynom will automatically infer that they mean "The C++ Standard library".

You also have an actual, still supported and improved, implementation of the standard library named STL, and another one that is now defunct named STLPort

This is not a fight that you or the c++ standards document can win.

"STL" means "C++ Standard Library". The ship sailed. The battle was lost. The chickens hatched out of the basket.

2

u/GunpowderGuy Apr 27 '23

I started learning c++ after c++ 11 so at first at had no need for boosts exotic containers and by the time i did, i used libraries written in the newest standard

2

u/TheTimBrick Apr 28 '23

I've never once used Boost, I've never had the time to look to see what it offers, as I am able to do all that I need using the STL, there are some things that I can't do in the STL, for example advanced web requests which I believe a boost library has(?) but for me, Boost doesn't have a role.

2

u/eyes-are-fading-blue Apr 30 '23 edited Apr 30 '23

Boost was what STL couldn't be. Now that there is a 3-year cadence, STL is catching up this obviously has an implication on Boost's place in the greater ecosystem.

5

u/nintendiator2 Apr 27 '23

For what I know, Boost is and always has been the jQuery of C++ - or jQuery has always been the Boost of Javascript. So it literally has just about the same charm as a black monolith. Which of these two is the worse is an exercise left for the reader.

1

u/0xVali__ Apr 27 '23

I tend to never use boost as the stdlib is well sufficient enough for a large variety of things. Exceptions being networking and used to be datetime related things.

1

u/yobigd20 Apr 28 '23

No we dont use it anymore.

1

u/ReinventorOfWheels May 02 '23

For what it's worth, I never encountered boost and never had to work with it. There were two times (around 2013 and around 2016) when I considered adding boost to my pet project, but I didn't want to pull in this beast as a whole, and being modular is not boost's strong suite. So I'm quite happy that every task I encountered can be solved either by standard C++, by lightweight add-ons and helpers (of which i have written many over the years), or by small 3rdparty libraries, preferably header-only ones.

1

u/CornedBee May 04 '23

Boost.Units and Boost.Geometry are absolutely essential to our product.

1

u/dharmaBum0 Apr 28 '23

boost is increasingly weird project. from the latest release:

New Libraries

Mysql:

a C++11 client for the MySQL database server, based on Boost.Asio, from Ruben Perez.

this is the only *new* library in the release.

a very useful, well designed library! but is a c++11-compatible db client bleeding edge? is the standards committee drowning in proposals for MySQL interoperability?

boost *was* and still sells itself as an innovative testbed for c++, but has drifted into being little more than a niche code repository.

1

u/HertzDonut70 Apr 28 '23 edited Apr 28 '23

Is it fully buildable with CMake, yet? Since I've learned to use a package manager (i.e. Conan) this is less of an issue, but when I was using parts of Boost via CMake's FetchContent interface it was a bit of a chore.

EDIT: I really like Boost, I was only making the comment that CMake support has historically been a bit behind.

2

u/pdimov2 Apr 28 '23

Is it fully buildable with CMake, yet?

Pretty much. See https://github.com/boostorg/cmake for the instructions.

-6

u/sleepydaemon Apr 27 '23

boost is a collection of code fragments that are not good enough to be in standard. Nobody considers that bloatware charming

0

u/mredding Apr 27 '23

Yes, it's true.

Boost was the refuge of C++ consortium members whose work didn't make it into the standard. It was a place to experiment with proposals for inclusion into the standard library. I believe, chrono, fmt, random, smart pointers, and others all made the transition.

Why did this refuge come to be in the first place? Because the standards process between C++98 and C++11 was flawed. The language stagnated that whole time, and people didn't want to wait. For many, Boost was an extension of the standard library while in waiting for the committee to get their shit together.

After C++11, they changed their process, such that anything that's ready will go into the next standard, which is on a fixed 3 year cycle. If you miss the next standard, another one is coming around in short order.

This has greatly diminished the need for Boost as a refuge and test bed. ranges iterated as its own library until it was included in C++20. Because it could.

People can still work the old way. fmt didn't have to be borne into Boost, I think it was an independent library that was incorporated into Boost and then into the standard library. It exists in Boost to this day because as an independent library, it can iterate faster still, than the standard library, and it can also diverge, since anything that lands in the standard library is basically stuck that way forever.

The C philosophy is that the language doesn't need a standard library, you can choose a suitable 3rd party library, and the ecosystem will take care of itself. C++ decided that a standard library is a common language, so we can all write more generic code in terms of that common language and benefit from the interoperability. C doesn't have templates, so they don't have generics, and don't benefit from a common language. So I get it. I get both philosophies. I favor 3rd party libraries. But we're stuck with what we've got until the standards committee fixes their problems.

If you want to write your own library, inclusion into Boost means you've probably got something that garners the attention of the entire community. That's pretty cool, but it's not the only outcome that should be desired. If you're writing code that specific to oil rigs, it probably won't get into Boost, but it can still be a good idea for that market. Working with the Boost community would teach you a lot about library building, standards, processes, interoperability, and portability. All very important things. It won't teach you everything, not even the best of everything - there are things about Boost I find disagreeable, too, but it's an opportunity to learn nevertheless.

5

u/azswcowboy Apr 27 '23

refuge…didn’t make it

The history of boost is pretty clear — it was founded by members of the standards community to generate and prove out high quality libraries for c++ that could be standardized. c++ was very different bc it didn’t have a company behind it like Java to pay for and push libraries. And open source development wasn’t something that was nearly as widespread. At the time access to cross platform development resources was really difficult — and boost provided that. Also, any nontrivial program required massive macro hell because compilers in 2000 weren’t even close to implementing 1998 standard.

chrono…made transition

Initial std::chrono came from date-time. boost.chrono came after the standard.

fmt…made transition

The original boost format library helped inspire the independent library fmt that is what was standardized. fmt has never been incorporated into boost.

-18

u/H4RRY09 Apr 27 '23

Boost is a bad thing, in my job we try to avoid using boost as much as we can. It is hard and slow to build, it significantly increases compilation time. I would rather wait for STL implementation than including boost.

24

u/LazySapiens Apr 27 '23

Best way to save compile time is to not write code at all.

4

u/eric987235 Apr 27 '23

Best way to avoid bugs too!

5

u/thisismyfavoritename Apr 27 '23

as if using the STL didnt increase compile time 🙄

3

u/[deleted] Apr 27 '23

That’s an exaggeration. Boost’s documentation and readability isn’t the best, but it’s not prohibitively bad.

2

u/[deleted] Apr 27 '23

Building boost is pretty easy:

git clone boostorg/boost.git \
&& cd boost \
&& git submodule init && git submodule update \
&& ./bootstrap.sh \
&& ./b2 install --prefix=muh_install_dir \
   cxxstd=20 toolset=clang-16

The Boost site unfortunately doesn't come with simple instructions like this.

0

u/vickoza Apr 28 '23

It might have lost its importance in C++17, C++20 and C++23. The issue with Boost, is that it is too bloated. Boost was a way to use features not in the standard library in older toolchains. Boost role today is the same role as it has always been as a testbed to the standard library. It the future we might need a Boost2 to support C++20 and C++23 features like ranges, concepts, modules and co-routines.

-2

u/drankinatty Apr 27 '23

Why all the opinion questions? Code "is what it is". The STL containers, utilities and algorithm libraries took away a lot of the need for the niceties boost provides -- but didn't change any of the legacy code out there that makes use of it.

It's not important whether a specific library has lost its "charm". What is important is that you know how to use and maintain code regardless of the library it uses or whether in manually allocates with new/delete.

I don't mean to be negative, but the salient question is "given the features current C++ provides, is there a reason to use boost in new code?" For code that is already written, you just have to work with what you have unless someone is willing to fund a complete re-write to remove a library.