What are the advantages of using the C++ Boost libraries? [closed]
Asked Answered
O

11

137

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?

Oxonian answered 24/9, 2008 at 5:35 Comment(1)
C++ is crap without Boost :)Contrition
D
152

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]
Disbelieve answered 24/9, 2008 at 5:48 Comment(5)
In addition, we can also say that boost sub-libraries can be used independently of each other (except a few core libraries). It is not because we are using boost.shared_ptr that we have to use boost.ublas, for instance.Lovesick
I love to see answers that look like encyclopedia entries. It makes it so easy to get a large amount of material. +1Doloroso
Althrough it seems that every library is dependent on MPL...Maishamaisie
Boost allows for write once, cross-platform development and usage correct?Amarillis
Is it free for commercial use?Monostome
B
44

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.

Brilliant answered 24/9, 2008 at 7:54 Comment(0)
H
24

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.

Holiness answered 24/9, 2008 at 5:43 Comment(0)
S
18

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.

Salchunas answered 24/9, 2008 at 6:59 Comment(1)
You forget that Boost is not one library but many. Additionally, you have to offset the large size and compile time against the functionality. Traits and concepts are a great help in development. Compile time is a small price indeed to pay for it.Rhino
B
9

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.

Blake answered 24/9, 2008 at 6:39 Comment(0)
H
9

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/.

Hummel answered 21/1, 2011 at 5:2 Comment(0)
P
6

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

Pharisee answered 24/9, 2008 at 5:38 Comment(0)
P
4

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.

Plascencia answered 24/9, 2008 at 6:17 Comment(0)
O
4

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

Outreach answered 24/9, 2008 at 6:56 Comment(0)
C
4

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

Crossquestion answered 24/9, 2008 at 7:46 Comment(0)
K
2

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

Killebrew answered 24/9, 2008 at 5:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.