What are the advantages of using the C++ Boost libraries?

C++Boost

C++ Problem Overview


So, I've been reading through and it appears that the Boost libraries get used a lot in practice (not at my shop, though). Why is this? and what makes it so wonderful?

C++ Solutions


Solution 1 - C++

Boost is used so extensively because:

  • It is open-source and peer-reviewed.
  • It provides a wide range of platform agnostic functionality that STL missed.
  • It is a complement to STL rather than a replacement.
  • Many of Boost developers are on the C++ standard committee. In fact, many parts of Boost is considered to be included in the next C++ standard library.
  • It is documented nicely.
  • Its license allows inclusion in open-source and closed-source projects.
  • Its features are not usually dependent on each other so you can link only the parts you require. [Luc Hermitte's comment]

Solution 2 - C++

From the home page:

> "...one of the most highly regarded and expertly designed C++ library projects in the world." — Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

> "Item 55: Familiarize yourself with Boost." — Scott Meyers, Effective C++, 3rd Ed.

> "The obvious solution for most programmers is to use a library that provides an elegant and efficient platform independent to needed services. Examples are BOOST..." — Bjarne Stroustrup, Abstraction, libraries, and efficiency in C++

So, it's a range of widely used and accepted libraries, but why would you need it?

If you need:

  • regex
  • function binding
  • lambda functions
  • unit tests
  • smart pointers
  • noncopyable, optional
  • serialization
  • generic dates
  • portable filesystem
  • circular buffers
  • config utils
  • generic image library
  • TR1
  • threads
  • uBLAS

and more when you code in C++, have a look at Boost.

Solution 3 - C++

Because they add many missing things to the standard library, so much so some of them are getting included in the standard.

Boost people are not lying:

> Why should an organization use Boost? > > In a word, Productivity. Use of > high-quality libraries like Boost > speeds initial development, results in > fewer bugs, reduces > reinvention-of-the-wheel, and cuts > long-term maintenance costs. And since > Boost libraries tend to become de > facto or de jure standards, many > programmers are already familiar with > them. > > Ten of the Boost libraries are > included in the C++ Standard Library's > TR1, and so are slated for later full > standardization. More Boost libraries > are in the pipeline for TR2. Using > Boost libraries gives an organization > a head-start in adopting new > technologies. > > Many organization already use programs > implemented with Boost, like Adobe > Acrobat Reader 7.0.

Solution 4 - C++

A few Boost classes are very useful (shared_ptr), but I think they went a bit nuts with traits and concepts in Boost. Compile times and huge binary sizes are completely insane with Boost, as is the case with any template-heavy code. There has to be a balance. I'm not sure if Boost has found it.

Solution 5 - C++

BOOST's a collection of libraries filling needs common to many C++ projects. Generally, they do prioritise correctness, reusability, portability, run-time performance, and space-efficiency over readability of BOOST implementation code, or sometimes compile times. They tend not to cover complete high-level functional requirements (e.g. application frameworks), and instead (thankfully) offer building blocks that can be more freely combined without dictating or dominating the application design.

The important reasons to consider using BOOST include:

  • most libraries are pretty well tested and designed: they generally get a reasonably sound review by some excellent programmers, compared to by people with home-brew solutions in the same problem space, and widely used enough to gather extensive real-world feedback
  • it's already written and your solution probably isn't
  • it's pretty portable (but that varies per library)
  • more people in the C++ community will have a head-start in helping you with your code
  • BOOST is often a proving ground for introduction to the C++ Standard, so you'll have less work to do in rewriting your code to be compatible with future Standards sans BOOST
  • due to the community demand, compiler vendors are more likely to test and react to issues of correctness with BOOST usage
  • familiarity with boost libraries will help you do similar work on other projects, possibly in other companies, where whatever code you might write now might not be available for reuse

The libraries are described in a line or two here: http://www.boost.org/doc/libs/.

Solution 6 - C++

It adds libraries that allow for a more modern approach to C++ programming.

In my experience many C++ programmers are really the early 1990s C++ programmers, pretty much writing C++ classes, not a lot of use of generics. The more modern approach uses generics to compose software together in manner thats more like dynamic languages, yet you still get type checking / performance in the end. It is a little bit ugly to look at. But once you get over the syntax issues it really is quite nice. Boost gives you a lot of the tools you need to compose stuff easily. smart pointers, functions, lambdas, bindings, etc. Then there are boost libraries which exploit this newer way of writing C++ to provide things like networking, regex, etc etc...

if you are writing lots of for loops, or hand rolling function objects, or doing memory management, then you definitely should check boost out.

Solution 7 - C++

Because the C++ standard library isn't all that complete.

Solution 8 - C++

Anything with Kevlin Henney's involvement should be taken note of.

Solution 9 - C++

Boost basically the synopsis of what the Standard will become, besides with all the peer review and usage that Boost gets you can be pretty sure your getting quite a good deal for your dependencies.

However most shops don't use Boost, because its an External Dependency. And in reality reducing External dependencies is very important as well.

Solution 10 - C++

Boost is to C++ sort of like .NET Framework is to C#, but maybe on a smaller scale.

Solution 11 - C++

I use the filesystem library quit a bit, and the boost::shared_ptr is pretty nifty. I hear it does other things too.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjdt141View Question on Stackoverflow
Solution 1 - C++blackwingView Answer on Stackoverflow
Solution 2 - C++Sébastien RoccaSerraView Answer on Stackoverflow
Solution 3 - C++Vinko VrsalovicView Answer on Stackoverflow
Solution 4 - C++jeramiahView Answer on Stackoverflow
Solution 5 - C++Tony DelroyView Answer on Stackoverflow
Solution 6 - C++Keith NicholasView Answer on Stackoverflow
Solution 7 - C++Hans SjunnessonView Answer on Stackoverflow
Solution 8 - C++Umber FerruleView Answer on Stackoverflow
Solution 9 - C++Robert GouldView Answer on Stackoverflow
Solution 10 - C++macbirdieView Answer on Stackoverflow
Solution 11 - C++Terry G LorberView Answer on Stackoverflow