The C++ Boost Libraries (Part 1 - Introduction)
Although I like to think of myself of a jack-of-all-programming-trades, I must admit that I am mainly a C++ man . I have dabbled in the seductive dark side of Java and C#, but still prefer the mad poetry that C++ code can generate. A few years ago, C++ was showing signs of its advanced years but this has changed with the Boost libraries - a set of weird and wonderful additions to the C++ standard libraries that really bring C++ into the current century.
I have been using boost for over a year, and I cannot claim to have scratched its surface. The parts that have found their way into my projects have all been well engineered and easy to use - each library goes through a lengthly review process before being part of the Boost distribution. It obviously pays off - several boost libraries are to be standard features of C++0x.
The Boost libraries fall into 3 main categories:
- Standardized cross platform APIs for modern OS features such as threading, filesystems, async-IO, and interprocess communication. Every project tended to roll their own half-baked wrappers, so it is nice to have some well thought out standard APIs for these features.
- New containers and algorithms that fill the gaps in the STL, such as the graph library and the string_algo functions along with various specialized mathematical operations.
- General low level helper libraries that add what amount to new language features. The bind library is perhaps the most useful example, allowing flexible function binding with arguments that works transparently with class members. I don't even want to know what voodoo it does under the covers, but I use it all the time.
Not all of Boost is ridiculously arcane and subtle. Take, for instance, the humble boost::logic::tribool class. From the documentation - "A tribool implements 3-state boolean logic" - which is useful for situations like the following:
boost::logic::tribool godExists = detectGod(); if (godExists) std::cout << "Good news - there is a God\n"; else if (!godExists) std::cout << "Good news - there is no God\n"; else std::cout << "There may or may not be a God\n";
See what I was saying about mad poetry.