January 30, 2015

Boost Your C++ Programming - page 2


  • October 17, 2005
  • By Ibrahim Haddad

LP: For programmers migrating from languages such as Java and C#, C++ can be a bit of a challenge initially. What do you think is the biggest hurdle for those programmers to overcome?

Well, memory management is certainly one big hurdle for those programmers. Another important difference between garbage-collected languages and C++ is how important RAII (Resource Acquisition Is Initialization) is in C++ designs. If a programmer fails to understand this importance--very likely it's a new concept--then he or she is bound to create less-than-perfect designs.

I also think that one major part of the hurdle lies in the perceived complexity of C++. While it is true that C++ is a very large language, with many special rules, it's not necessary for most programmers to understand all of it. For example, I have worked with many C++ programmers who don't know anything about templates, but they can still be productive using C++. So, a lot of the complexity is not relevant to many programmers, and thus the hurdle needn't be so hard to overcome. Of course, knowing which parts are most important to understand is itself a problem.

LP: How can the Boost libraries facilitate the life of C++ newcomers?

In many ways! One advice that I constantly give is to use smart pointers all the time, and avoid raw pointers whenever possible. If you're new to C++, you definitely should learn to use smart pointers--I recommend the ones in Boost.Smart_ptr--so you won't have to worry so much about memory management. If you use Boost.Filesystem, you will be relieved of the tedium of learning platform-specific file and directory APIs. If you use Boost.String_algo, you'll get access to many important string algorithms, rather than write them yourself. With Boost.Regex, you'll have access to powerful regular expressions. The list goes on and on--most of the libraries in Boost are well suited for any C++ programmers, neophytes and experts alike.

LP: What do you see as C++'s greatest strengths? Weakness?

Strengths that are important to most people include how well the language supports large-scale projects, the powerful support for generic programming, and how well the language supports extensions through libraries. Of course, efficiency is another major motivation for many C++ programmers, a property that goes hand in hand with the support for low-level constructs. The most important weakness is definitely the size and complexity of the language. As I said earlier, the complexity need not be tackled by everyone, because not all of C++ is relevant to all programmers--but it isn't so easy to know what is important and what's not.

Sitemap | Contact Us