Survival Rules for Newbies
First Rule : If have no interest in investigating the nuances of a complex language, then maybe you should not choose C++ .

C++ is harder to master than interpreted languages like python. However, C++ can offer a good amount of syntax sugar without big runtime performance penalty. In fact, the development of python programs with performance similar to a good C++ code is quite hard even though the python itself is easy to learn. The speed gap between these two langagues increases even more when you start using concurrent libraries like Intel TBB. Interpreted languages also requires extensive use of external libraries and wrappers that are not nearly as mature and stable as mainstream C libraries like GSL and NAG.
Second Rule : If you want to learn C++, follow google style strictly until you master their forbidden rules .

Don't rush and be simple. Exceptions and RAII, for example, are powerful techniques but they can cause serious problems if used without knowledge. It takes time and effort to master them. After that, however, you will see that RAII considerably help you to manage memory allocated by C libraries, like GSL/NAG.
Third Rule : If you are self confident about your C++ skills, you probably overestimate your C++ understanding .

C++ is hard. You must think carefully before inserting a particular aspect of the language in your program and that is why development teams tend to limit the number of C++ features that are allowed on their projects.
Fourth Rule : Choose carefully the numerical libraries you use in your program .

This is my main criticism against (many) Python users. Many of them tend to use numerical libraries that are far from being mature. Decades of work are necessary to develop reliable numerical libraries. Even tough GSL is available for more than 10 years, you can still check the existence of a non negligible amount of recently fixed bugs that are dangerous and hard to detect in the GSL bug list. All the mainstream libraries I am aware of are written in C with few exceptions like Armadillo and unlike interpreted languages, C++ can call C functions without the need of a wrapper.
Fifth Rule : Avoid writing heavy numerical work in C++ .

This title is sensacionalist. If you have to choose between C++ and interpreted languages, I have no doubt that it is safer to write the numerical kernel in C++. You may also advocate that C++ is safer than C for numerical kernels because of its stricter type safety rules. Even tough I share this belief, I use C for heavy tasks because C compilers are better in optimization. In practice, it is good enough to delegate the heavy numerical work to GSL or NAG and leave everything else in C++. This advice is especially important if you use Numerical Recipes because I believe the "syntax sugar" they introduced in the new version of the book was not worth the potential performance hit.
Sixth Rule : Don't blindly trust C++ wrappers .

Wrappers with untested quality can be quite dangerous. With simple tricks, it is possible to call C libraries without losing most of the syntax sugar C++ can offer. One example of a wrapper I don't trust is the official C++ CFITSIO wrapper because its implementation seems to be heavily based on std::valarray and std::auto_ptr. This is a bad implementation decision because std::auto_ptr is deprecated and std::valarray team left the standard committee more than a decade ago. Another example: GSL wrappers probably use static functions and manage themselves the allocation and deallocation of heap memory and this can make your code to not be thread safe even tough GSL itself is thread-safe.
Seventh Rule : Always use the pointer "this" when you refer to member variables or member functions .

Remember: people don't know about your particular naming convention. Once at work, a friend who is a C programmer had difficulty in identifying the location of member variables definitions because they look like global variables for C programmers. The use of the pointer "this" helps them to identify that a particular variable is owned by a class.
Eighth Rule : If you have a piece of code that can be easily generalized to avoid repetition then implement it as a global function .

When we learn C++, our first impulse is to write everything inside member functions. However, member functions are tied to a particular class and if another class needs similar behavior, you will face the problem of copying and pasting lines of code that requires only small changes to be used by a different class. Smaller code are easier to update, maintain and debug. So whenever you have a small piece of code that can be generalized to avoid repetition, implement it as a global function. The only exception is the code located inside the bottleneck routine of your program because higher level of indirection may imply worse performance (if the compiler is not able to inline your calls).
Useful references
Google C++ Style
List of Books I highly recommend
My favorite reference website for formal definitions
My favorite reference for common issues (be careful about copyright if you copy pieces of code from this website)
Runtime memory/cache debugger
Articles arguing that expression templates is not the optimal technique for matrix multiplication
Smart Expression Template.
Only a wrapper to low level libraries. Fix expression templates.
Armadillo C++ Linear Algebra Library.
The most famous linear algebra library in C++.
Non commercial free license of intel C++ compiler.
Useful pieces of code
Wrapper to GSL Functions.
Code that read input files
Wrapper to GSL interpolation routines
Deleter Class that allows C++11 smart pointers to manage the memory of some GSL structs
Wrapper to GSL 1D Find Root routines
Libraries I frequently use
Libraries I don't use frequently in my work but are trustworthy
Libraries that allows you to create GUI
Home