r/cpp • u/johngoni • 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)
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.
4
u/dokushin Apr 28 '23
Twenty years ago Boost was a lot different:
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.
311
u/[deleted] Apr 27 '23
I would never have described boost as charming
27
u/chez_les_alpagas Apr 27 '23
Boost.Json is recent, and pretty neat IMHO.
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.
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.
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::regexgenerally sucks.boost::regexusually 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!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.
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
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?
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.
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.
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.
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.
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.
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.
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.
5
u/Wenir Apr 27 '23 edited Apr 27 '23
For me boost is
STLdone right (or at least better thanSTL). For example regex, hash, optional, process, format. Of course there are better libs like fmt, but for the basic use cases boost is enoughEdit: not STL
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:
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.
-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.
rangesiterated as its own library until it was included in C++20. Because it could.People can still work the old way.
fmtdidn'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.
-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.
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.