Does it make sense to restrict yourself to the STL libraries when learning C++ and then tackle boost and its additions after you have become fairly proficient with vanilla C++?
Or should you dive right into BOOST while learning C++?
Does it make sense to restrict yourself to the STL libraries when learning C++ and then tackle boost and its additions after you have become fairly proficient with vanilla C++?
Or should you dive right into BOOST while learning C++?
It depends entirely on whether you're going to be able to use Boost in all your work. I don't doubt that there'll be workplaces that will forbid its use (however silly that may seem).
But, if you think you'll be able to use it anywhere, then by all means concentrate mostly on it.
If there's functionality provided by the STL but not Boost, concentrate on learning those bits of the STL.
First go with STL because that is what you will be using most of the time. Mastering all the boost is really hard, check with boost for any library that is not available with c++ out of box.Like parsing library,graph library
I'd suggest getting a clear handle on STL, before looking at Boost. Boost is meant to build on top of STL and many of the libraries are slated to become part of the standard library eventually. Boost libraries are generally less mature and less standard than STL. Also, many boost libraries go too far, in my opinion, adding "features" that don't natively exist in C++ (leading to really insane syntax). In many cases there are more sane C++ idioms available for solving most programming problems without using these arcane Boost libraries.
I'd go with learning STL first.
Once you're past the basics with C++, learning how to use parts of STL and then how it works will be better than tackling Boost. The Boost libraries tend to push the edges of C++ especially in combinations of highly-templated functions.
I like Matt Austern's Generic Programming and the STL which you can pickup cheaply secondhand.
The STL has some core concepts to it. Boost builds on and expands on them. If you understand them, then moving right on to Boost may be of use to you. If not, I would start with the STL.
vector
, list
and deque
, and associations like map
, set
and their multi*
and unordered_*
varieties). Sometimes you can swap one for the other -- sometimes you can't. Know their strengths and their limits.copy
differs from copy
specialized for const char *
).bind1st
, ptr_fun
and mem_fun
): the syntax can obscure their utility.string
-- and when not to use it. (All string classes have tradeoffs: learning the pros and cons of the standard one is educational).The principles used to design the STL are built upon and expanded on by the Boost libraries. If you get them, Boost is manageable. If you don't, and Boost ends up hard to follow, you can go back to the STL to get your bearings.
(In general Boost really pushes the boundaries of the language. If you decide you want to really push your own knowledge of C++, and test if you really know what you think you know then it can provide an interesting challenge. I've used C++ for more than a dozen years, have taught other people how to use it, have acquired proficiency in many more high-level languages since then and Boost still surprises me. It's very useful, but its not trivial).
I think it's fine to use both straight from the start. Boost provides many powerful features, is widely used, and has a good reputation. Most of the things it provides share the same generic-programming concepts with which the STL was designed, so in that sense it should not be very confusing.
The best way to learn something is to use great code and then go and see how it was written. This worked well for me with Boost. Read a templates tutorial, and you're inspired by the new power you discovered for an hour. Then read a Boost header that you've been using for a bit, and you'll be inspired for weeks.
Of course, don't expect to understand those internals immediately - at first I just used the libraries without understanding how you would build any of that, and that's fine. But at some point you realise you want to write something with a similar design, and then you'll go looking.
If you'd do the opposite, and restrict yourself to "C++ as a safer C", then you wouldn't be exposed to all these powerful things, so you wouldn't be as tempted to look and understand them, and so you would write rather primitive code and learn more slowly.
EDIT: forgot that I had another thought - have a look at the upcoming C++0x standard too. It incorporates many features that originated in Boost. That is, students who start learning C++ a few years from now would be working with these concepts from the very start - you might as well do that today too...
Learn by programming and use the tools best suited. If you're programming something that needs a lot of parsing then you'll maybe learn some of boost spirit, but before you get that far you'll also have learned stuff about std::string and std::fstream. the next app you write will maybe need std::vectors and boost::accumulators.
Just remember boost is huge, you'll be a good quality programmer way before you've used even a quarter of it (personally I don't expect to ever use or learn most of boost because I don't need it...).
Ultimately, you should learn both. But STL can be learned in isolation, whereas boost won't make much sense until you understand the STL, since that's what Boost is modeled on, and designed to extend. So learn to use the STL as part of learning c++. And then you can move on to Boost, which is more or less the "second standard library" these days.