February 20, 2019

Boost Your C++ Programming - page 4


  • October 17, 2005
  • By Ibrahim Haddad

LP: There is a large Boost community. How to get involved?

The best way to get involved is to download the Boost libraries, start learning about them, and join the Boost Users mailing list. There, you'll find thousands of interested Boost users and developers, and you can get answers to your Boost questions, and hopefully provide answers for others! There is also a mailing list for Boost developers, where you can join to participate in the discussions of potential new libraries, propose libraries of your own, and take part of the formal reviews of proposed libraries. The Boost community is large, but it is also very personal.

LP: Was it a fun process to write the book? What did you learn through the process?

Writing a book is tremendously rewarding, and a lot of fun. There's one thing that I really wish I had known when starting out though--how much effort it actually takes to finish a book. Starting out is quite easy. You write a book proposal, a sample chapter or two, and start talking with a publisher. Then, suddenly, you have a looming deadline, 400 pages left to write, hundreds (or even thousands, but don't count) of hours doing research, reviews to schedule, changes to incorporate, rewrites when you thought you were already done, and so on and so forth. You need to prepare for all of those things, but as a first-time author, I didn't. Anyway, looking back, none of that really matters, because the joy of writing, and the idea of helping fellow programmers to improve their game, is what it's all about. I guess the most important lesson in writing books that I've learned is that it's a lot more work than you think, so prepare for that. And I think the best way to answer the question "Was it fun?" is by telling you that I've already started working on my next book.

LP: If you are to advise (1) a computer science college student and (2) a professional C++ developer on the must-know and must-use Boost libraries, what will those be?

I think that there are a number of "basic" Boost libraries that both computer science students and C++ professionals should carry in their toolbox. These include Boost.Smart_ptr, Boost.Bind (a library for binding functions, extremely useful when dealing with STL algorithms), Boost.Operators (for helping you define correct operators for your classes), Boost.Regex (for regular expressions), Boost.Signals (for creating flexible callbacks), Boost.Any and Boost.Variant (for your variant data types needs).

Although it is hard to give general advice for computer science students, I think that there are a few libraries that are especially interesting; Boost.Graph is an excellent library for creating and manipulating graphs and comes with a nice set of graph algorithms. Boost.Interval helps manipulating mathematical intervals. Boost.Random is a very strong random number library. Boost.Spirit is a great parser framework that allows you to express an approximation of EBNF right in your C++ code. Finally, for basic linear algebra there's Boost.uBLAS.

For professional C++ developers, it's even harder to give general advice, because so much depends on what problems they typically address. That said, I'd encourage most to have an understanding of the libraries recommended for computer science students, and then add some: Boost.Conversion for controlled conversions between types; Boost.Date_time for representing date and time; Boost.Function for storing functions and function objects for later invocation; Boost.Enable_if, which demonstrates a very interesting use for SFINAE to selectively include or exclude function overloads; Boost.Iterators for creating new iterator types or transforming existing ones, Boost.Lambda to create function objects at the call site; Boost.Mpl for dealing with your meta programming (this is a truly awesome library!), Boost.Multi_index for containers with multiple indices, allowing you to search efficiently using different criteria, for example; Boost.Preprocessor, a library which brings some order into the chaotic world of macros; Boost.Signals for callbacks; Boost.String_algo for a set of very useful string-related algorithms; Boost.Test for unit testing...

I'd better stop now. As you can see, there's an abundance of useful Boost libraries, and I honestly believe that the number of must-know and must-use libraries is quite close to the total number of libraries in Boost.

LP: Why do you think Boost is important for the future of C++?

There are two main reasons why Boost is so important. The first reason is that the libraries follow the design of the libraries in the C++ Standard, and are therefore suitable for extending the C++ Standard Library. Evidence of this can be seen in the TR1 (Technical Report 1), where 12 of the 14 new libraries come from Boost. The second reason is that the Boost community consists of people who actively work with the evolution of C++, often as members of the committee. The future won't change without the active participation of talented people, and I think C++ has once again gained momentum in that aspect.

LP: Why should C++ programmers get a copy of your new book about Boost?

Because it will help them to learn more about the Boost libraries in a much shorter time than it would if they try to figure it all out on their own. I hope that the book conveys my enthusiasm for the libraries, and that my readers will feel the same enthusiasm when they start being more productive with the help of Boost. The book also provides many explanations of how to implement key functionality of the libraries, which will show readers important techniques to use in their own designs.

LP: Are the Boost libraries mostly used in the open source world? Both open source--applications as well as libraries--and commercial products are using Boost. I think that it's safe to say that the open source world was quicker to adopt Boost than most commercial companies, but that seems to be changing. For example, companies such as Adobe, SAP, and McAfee, are all using Boost libraries.

I'd also like to add that there are Linux distributions that include pre-built Boost packages, for example Fedora, Debian, and NetBSD. I think that's great for Boost, and great for the users of those distributions!

Most Popular LinuxPlanet Stories