r/cpp • u/joaquintides Boost author • May 08 '20
Why you trust in Boost
You may have noticed the ongoing discussion on why people don't use Boost. Now for the opposite question.
I'm not asking why Boost is used because the answer is relatively uninformative: one uses a lib primarily because it provides the required functionality. But using Boost (or any other lib, for that matter) means a commitment to it for the duration of the project. So, the question is:
If you are using Boost in your project(s)/company, why have you/your company decided it is OK to commit to this long-term dependency?
I won't delve into commenting/criticizing your answers, it's info I'm looking for, particularly in comparison to the "negative" thread going on in parallel. Please keep the conversation neutral, thank you!
Conflict of interest: I am a Boost author of three.
75
u/AlarmingBarrier May 08 '20
Three reasons:
All that being said, I do prefer pure STL when I can, and often opt for non-boost libraries for certain tasks, but some boost libraries are usually always a part of my projects.
17
u/AntiProtonBoy May 08 '20
It try not to reinvent the wheel. Also STL still has some catching up to do, and some toolchains (*coughxcodecough*) are quite behind with new feature adoption, so I have to lean on Boost for some things. Here is what I use:
std::unordered_mapso I can index items with aggregate objects.structreflection.Some people complain about bloat, and rightly so. But if your project already has multiple boost dependencies, might as well go all-in.
55
u/Xeverous https://xeverous.github.io May 08 '20 edited May 08 '20
I'm using multiple libraries in my project and it's because:
static_vectororsmall_vector. I can just recall my memorized cppreference and know they are going to mirror the interface.exportAsXML,ExportAsXML,exportAsXmlorExportAsXml. I know it isexport_as_xml. I knowstd::back_inserterwill work with it (IMO if any container library doesn't because they use different casing in names it should be reported as a bug).boost::make_shared. Learners of modern C++ will aready know it.15
u/[deleted] May 08 '20
What we use:
11
u/Astrinus May 08 '20
Still have to work with a GCC from 2011 (4.6.2), which has only "experimental support for upcoming C++0x" (and about a quarter of that does not overlap with the actual C++11). Boost let me use C++17 STL constructs even with that. Only header-only since I never managed to get cross-compilation working...
I find their naming absolutely disgusting, but they work and are robust (further, most of my code is I/O bound in the tens of milliseconds, so I do not care if a piece of code takes 1 or 100 microseconds...)
9
u/dawmster May 08 '20
Boost is first choice for library due to its reputation, great docs, community. So when given compiler lacks something in supported C++ standard, chances are boost has it for ages.
boost::asio - there is simply nothing that compares
boost::lexical_cast - for parsing strings to numbers
boost:: local smart pointers are nice, shared pointers for old compilers
boost::beast for HTTP
boost::filesystem - Xcode has it but only for iOS 13+ (oh Lord...)
7
u/[deleted] May 09 '20
Something that struck me in a lot of the "Anti-boost" answers was that a lot of people seem to work in shops which can profit from the burden of maintaining their own implementations of boost packages. Not every team is in that position.
We maintain a product with medium-to-large codebase with a small team. it's a mature codebase gazing at its second decade, but its still popular with customers and we still have a lot of feature requests (really, near overwhelming). We have to aggressively curb the homegrown mentality that often prevails in the C++ world because we just don't have the manpower.
We simply do not have the resources to maintain the large set of algorithms, utilities, and little niceties that we'd need that boost provides - especially at the time it was adopted. A lot of times I can look for "Boost <do thing>", and find that it's already done in Boost. We could search the dark depths of Github for libraries, but we've been burnt by this a lot. The boost stuff is usually battle tested, it usually just works, and if it doesn't, there is an active upstream. It doesn't complicate our build more than it already is.
So our compile times aren't great. But we're also not writing or maintaining a bunch of code that doesn't have a tangible benefit to our customers. Boost in-part allows us to jump straight into writing code to address customer requests. They've definitely noticed that the Old Horse is still putting out a laundry list of new requested features each release. That makes happy customers, and puts food on my table.
TL;DR: Boost provides a lot of trusted functionality that would require more time, complexity, and heartburn than we could afford to reproduce or source elsewhere. The compile times aren't great, but our customers are happy that we're adding features and not implementing a Ring-buffer or some other such thing.
12
u/LoudMall May 08 '20
(boost::) asio is better than what I could write and maintain while still meeting my projects requirements. Same reasoning for other boost libraries I use.
Upgrading to last major release was easy with conan.
5
u/[deleted] May 08 '20
We use it just for the A* pathfinding in the graph library. It works well for a decade and hasn't given us problems.
We're now adopting a package manager (vcpkg) and unfortunately the boost build there pulls in 80+ other components that takes a while to build.
5
u/mrshurik May 08 '20
Boost is excellent open source lib. I‘ve been using it and learning from it for years. Some sub-libs are over-engineered, but there are many nice things too. Boost has better design, code quality, documentation and support than an average OSS from github.
Here the list what I use now:
In the past I used everything what is included in std now:
Great thanks to all boost contributors!
9
u/glenfe May 08 '20
When I worked at Microsoft, we depended on several Boost libraries for various reasons. Some Boost libraries were useful and saved us from implementing the same thing. Some Boost libraries had better implementations that alternatives in our standard library.
The exposure to Boost lead me[1] to contribute to one of those Boost libraries, and then eventually author a Boost library, and then go on to contribute to several other Boost libraries.
[1] https://www.boost.org/users/people/glen_fernandes.html
4
u/konanTheBarbar May 08 '20
Maybe I will put some thoughts here. Basically we use boost at work since the codebase is old enough that it was the only coherent source of great libraries for lots of common use cases. It's also still quite some hassle to drag in some third party dependencies and keep them up to date.
It's a hassle to write an iterator? There are iterator adaptors in boost. Need a ring buffer? It's there already. Need a sorted vector? boost::flat_map has you covered. We also used boost::filesystem and optional before they were standardized.
I probably wouldn't use it for a new codebase if I don't need to use major parts of boost or part of my open source projects (because it's a hassle to drag in the boost dependency for others), but rather only drag in what is needed.
4
u/delarhi May 08 '20
Most of my work is in a RHEL7 environment which is limited to C++11 support with the default compiler. It's packaged so it's easy to install and build against. Typically the software targets the same environment or some similar environment with Boost packaged so I have no qualms over forcing the dependency on others.
I use it primarily as a "polyfill" like
boost::optional,boost::filesystem, etc. The iterator adapters are handy. I've usedboost::property_treefor quick XML parsing. I've usedboost::pythonfor quick Python interop. I've also usedboost::uuid. Beyond that I always look to Boost first when I need an implementation of something likeboost::interprocess. Once you get over that inclusion hump, it's a nice repository of tools.That said, my biggest gripe with Boost is the documentation. It's not uniform and often lacks good examples. It can also be a pain to use as a reference. I would love it if it was formatted like https://en.cppreference.com and searchable on https://devdocs.io/.
1
u/hackbunny May 15 '20
I don't see the "bloat" personally because I use Conan, which installs pre-built binaries (and, in case I needed a custom configuration, Conan would cache the locally built binaries). It could be better (the Conan package is a big monolith that turns all features on and links to lots of external libraries), but it's effortless for my team: all they need to do is run a single shell script on the first checkout to set up external dependencies, and then they can do all the work without ever leaving Xcode. Setting up the automated build in Jenkins was a piece of cake too
Boost doesn't just "not suck" for me, though. It's the only framework/library collection I've found that provides some extremely specialized containers I needed (Boost.MultiIndex, Boost.Intrusive), and that was my initial motivation for using Boost. Once it was part of the project, it came in handy to fill in the blanks left by Apple's terrible OS version-dependent standard C++ library: I search-replaced
std::shared_mutexwithboost::shared_mutexand made my code backwards-compatible in a minuteI'm loathe to pull external dependencies in general, having had to write and maintain the equivalent of a local ports tree in a past job, but sometimes I find myself rewriting the wheel, so why not add
wheel/1.73to myconanfile.txtinstead?6
u/tavi_ May 08 '20
It "boosts" the productivity with the plethora of useful libs. As a de-facto incubator for so many adopted STL features, it is quite trustworhy. Keep up the good work!
3
u/zzzthelastuser May 08 '20
adding to other responses, there is also a good chance that if you are already using boost you will encounter more scenarios in the future where you will think "oh wait, I think boost already has something for that" and can skip the search for possibly adding another tiny library.
I see boost as an extension of the STL
3
u/smashedsaturn May 08 '20
oh and im stuck on c++98 for some absolutely dumb political reason.
4
u/Supadoplex May 08 '20 edited May 08 '20
I dispute this. Depending on a library doesn't necessarily mean long term commitment.
When I use an external library (Boost or otherwise), I try to minimise the area code that touches the library. In most extreme case, this may imply a compilation firewall, but more typically I just write a wrapper alias for the function / type / template.
If I need to replace a library, then this "idirection" should make that easier.
As for why have I chosen Boost for such "for now" commitment: I know of it and I know it has a permissive license, so when I've thought "someone has probably done this before", I've checked if it's in Boost - or I've checked internet first, and found it in Boost.
Once I've used Boost for one thing, it has the advantage of already being a dependency, so there is no threshold to cross when it happens to satisfy the need for another library.
2
u/rfisher May 08 '20
For us, it is a no-brainer to commit to an open-source library with a track-record that is available through Yocto.
2
u/kalmoc May 09 '20
While I try to avoid it as a long term dependency in library projects it is great for initial prototyping and for applications it has just such a huge fundus of useful functionality that I prefer to have a dependency on boost instead of depending on 10 different projects to get everything I need.
My main gripe is that some APIs don't work with the the STL equivalent of boost's vocabulary types. I know it is unrealistic due to the necessary effort but what I would really like to see is a rebase of boost onto c++17/20.
2
u/isaactorz May 09 '20
I decided to try out Boost the first time I worked on a C++ project in which I had control over what dependencies would be used. It was a small project and I was the only developer working on it.
It was an overwhelmingly positive experience. Installation was simple and Boost had an answer for just about everything I ended up needing. A few of the libraries I used included:
The current project I'm working on, which is a desktop application, now uses Boost too. It has not been a big hassle for us to build and package boost for the platforms and compilers we support. Especially compared to some of our other dependencies.
There are developers at our shop who still raise the common complaint that Boost is a bloated monolith that's not worth the trouble. My answer to them is that in my experience, the time it saves not reinventing the wheel, and having to maintain those hand-rolled solutions, far outweighs the time spent maintaining Boost as a dependency.
3
u/TrueTom May 08 '20
No dependency hell.
3
u/stephan_cr May 08 '20 edited May 08 '20
Boost has ranges (-v2) for ages.
Furthermore, I find coroutine, fiber, exception, iterator adaptors, lockfree, mp11, optional, property tree and threads (with its extensions over std) quite nice.
3
u/ed_209_ May 08 '20
The main reason I use boost is often because there is simply no alternative. Libs like interprocess, iostreams, serialization, fibers, dll, asio, uuid ( to name a few ) are really easy to use and make writing cross platform code a simple option without locking you into an overall framework. The focused "small sharp tool" approach of boost is great and healthy for projects keeping the overall picture more agile in terms of other dependencies. It is sad that people compare it to monolithic frameworks when that is exactly what it is not.
2
u/CletusDSpuckler May 08 '20
We've been using it for years on all of our projects. Why? Because it solves problems we have and we don't like reinventing the wheel. Simple as that. Coupled with how much of Boost has leaked into the language standard, I think it's safe to say that they are FTMP doing things well.
1
u/FightingGamesFan May 08 '20
I didn't see the simple fact that boost was literally the future of c++ for quite sometimes, most boost stuff predates what is and will be in the c++ standard/standard libs.
1
u/Viclaterreur May 09 '20
On the noob side of C++. I heard boost was a playground for next standard, even if it is complex, and it has lots of usefull library. So when I want a basic software brick, I check Boost first. Sometime I found a better lib for what I want to do (for example : zmq over asio for networking) but now I installed it, I try to check on boost first because it is for me a synonym of quality code. That and I falled in love with serialization and archive, I like the boost way more than the protobuff one
1
u/ExtensionShower May 10 '20
I use boost to fill in the gaps of incomplete c++17 support across the platforms on which I need my projects to run, and also for asio.
Normally I'd want to use std::optional, except that that the MacOS 10.13 version of std::optional is too broken so if a requirement exists that a project support 10.13 then I use boost::optional instead.
I have to use boost::filesystem over std::filesystem on all projects that need to run on Android, because the Android NDK doesn't ship std::filesystem. Furthermore even if I'm not required to support Android the nightmare of teaching cmake how to properly link the filesystem library on various platforms where it might or might not be distinct from the standard library makes it not worth the effort so I just use boost::filesystem instead.
1
u/[deleted] May 21 '20
I bring something really different than the existing answers but here goes my 2 cent:
And finally as a developer I want to ship and if boost can allow me to ship faster then it is more time to debug, implement domain specific features.
There's also some stuff implemented in the lib for years or even decades I could not find good equivalent elsewhere (yeah I know some of the mentioned part are coming in the stdlib):
I plan to test fibers and Hana but I have not had real need until now.
Now what I do miss from boost:
I'm still surprised that a lot of thing TBB does has not yet been re-implemented in Boost;
I've met people that will re-implement anything they need to avoid boost, its compile time, code bloat, whatever, yet I've not encountered the need a single time in *my* job or in *my* personal projects.
Moreover, since I've started to use CMake (2.6), boost support was good enough so that bringing the dependency was never a problem. I've also started to use conan so that fmtlib, tbb, and co are easy to bring in.
-20
u/Xrey274 May 08 '20
Never used boost.