42

Possible Duplicate:
Boost Library

Often when I was trying (and failing) a C++ project I run into Boost when browsing the web. I tried reading the Boost website, but there was no good short description why to use Boost and what it exactly is.

One of the things that I like a lot about Python is that everything is built-in and cross-platform, web requests, email, XML, JSON, etc. Is this also the case with Boost?

So, enough rant, my concrete answer-able questions:

  • What exactly is Boost?
  • What are the most import reasons to use Boost?
  • Is it fully cross-platform?
  • Is it more "safe" then regular home-brew code where you quickly overlook that one buffer overflow, etc?
  • Is there any link to a page describing all the modules of Boost in one or two sentences?
Community
  • 1
  • 1
orlp
  • 112,504
  • 36
  • 218
  • 315
  • Also see http://stackoverflow.com/q/125580/50079. – Jon Jan 13 '11 at 16:26
  • 9
    To answer the question nobody is answering, the boost libraries do not do the same kind of nuts and bolts practical stuff that the Python libraries do. No XML, no JSON, no email, no HTTP handling. The boost libraries are both more abstract and more low level than that. Still incredibly useful for all that, but a different kind of useful. – Omnifarious Jan 13 '11 at 16:32
  • 1
    @Omnifarious: Thanks, that was one of the most important parts of my question. – orlp Jan 13 '11 at 16:40

6 Answers6

47

What exactly is Boost?

Boost is a collection of useful and extremely high-quality libraries for C++ that complement the rather small standard library.

What are the most import reasons to use Boost?

Boost offers high-quality tools that are missing from C++. Their use is extremely varied though so whether Boost is for you depends entirely on your needs. But I can safely say that every large enough C++ code base would benefit from using Boost.

Some of the most versatile parts are the shared_ptr (a reference-counting smart pointer that helps prevent memory leaks in pointer-rich code), array which provides a very convenient wrapper around C-style arrays of fixed size and other small odd bits which have been integrated into the next C++ standard.

Is it fully cross-platform?

Almost always yes. This is one of the main qualities of Boost.

Is there any link to a page describing all the modules of Boost in one or two sentences?

There is indeed.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • 6
    Just using `boost::shared_ptr` or `boost::scoped_ptr` in your code and never writing `delete` anymore is one good reason enough to use boost. – Alexandre C. Jan 13 '11 at 16:29
12

1) Boost is a set of APIs, developed by some of the best minds in C++. You can use as much or as little a you want. Each API targets, and solves a particular paradigm. For example:

lexical_cast<>  - Type-safe ways of casting from one type to another.
program_options - Library for parsing command lines in a type-safe manner
asio            - Asynchronous Input/Output.  Great for working with sockets, IP4/IP6
shared_ptr      - Reference-counted smart pointer

... and many more.

2) One of the most important reasons to use Boost is that the great developers that have done this, have, well done it. These solutions are peer-reviewed and robust. If you have a problem to solve and Boost has an API that fits the bill, chances are you should be using it.

3) It's about as cross-platform as you're going to get. i.e, yes.

4) I would use boost over anybody's home-brewed code. Homebrew tends to get used by a single developer (the person that coded it). Boost is in use in commercial applications everywhere and as I said earlier, it's peer-reviewed. You don't get much more robust than that.

5) The main boost page has a list of libraries by function and alphabetically.

Moo-Juice
  • 38,257
  • 10
  • 78
  • 128
  • Was c++11's `std::_shared_ptr` taken from boosts `shared_ptr`, correct? Then they are relatively identical, hmm? – knoxgon Sep 15 '17 at 15:34
10

What exactly is Boost?

Boost is a collection of C++ libraries that help you avoid writing custom code to solve common problems.

What are the most important reasons to use Boost?

Boost saves you from having to design, implement and test the solutions it offers. This save you a tremendous amount of time and helps you avoid bugs along the way.

Is it fully cross-platform?

Boost supports many platforms, sometimes catering solutions to be efficient on particular platforms. You can see the platforms on which it has been tested, near the bottom of the current version page under the Compilers Tested heading.

Is it more "safe" then regular home-brew code where you quickly overlook that one buffer overflow, etc?

Yes, unless you have a lot of time to spend testing your code. Boost includes an automated test suite and is tested by hundreds of thousands if not millions of developers via daily usage. It also has a lot of documentation that helps you develop with the libraries it includes. Boost is not only more safe than most home brewed code, it is also, in general, more performant.

Is there any link to a page describing all the modules of Boost in one or two sentences?

The Boost Library Documentation links page offers a one sentence summary of all of the libraries in Boost.

Michael Goldshteyn
  • 71,784
  • 24
  • 131
  • 181
3

Boost is a collection of classes and other things for C++ that are missing from the STL. A lot of the libraries in Boost are being included in the new C++ standard. Its definitely a lot safer than what you'd be able to come up with since this code is widely used and peer reviewed. Its typically full cross-platform, but there may be some gotchas.

As for what is in boost, check out this: http://www.boost.org/doc/libs/1_45_0/?view=categorized

Mark Loeser
  • 17,657
  • 2
  • 26
  • 34
3

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

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

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252
2

Anything that boost page on wikipedia doesn't answer?

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
tibur
  • 11,531
  • 2
  • 37
  • 39
  • To me, the aim of Stack Overflow is not just answering questions. It's also a matter of collecting and sharing knowledge. In my opinion this kind of answer does not provide any value to the community. – turbopapero Mar 05 '17 at 21:08
  • @auserdude Agreed! Posting some other web page without explaining self-soaked knowledge shouldn't be allowed in SO. – knoxgon Sep 15 '17 at 15:36