Scientific programming

Shaman introduction to C++

by Nikolai V. Shokhirev

Work in progress

Up ABC tutorials

Up: Scientific programming
Previous: Numerical objects
Next:  Project environment

Introduction

You are a professional, a specialist in your area of expertise. For some reason you have to program in C++. You are not a "C++ guru". However, you already have a huge advantage over any computer scientist or guru: you know what to program. C++, Fortran, Matlab, etc. are just tools in your professional toolset. You simply want to use these tools effectively, probably without knowing all "bells and whistles".

C++ has its specifics. It is a combination of a low-level procedural C, its object-oriented extension, generic (template) extension, and the STL. The polite way to express this is: "C++ is a federation of languages" [1]. The combined grammar is complicated. C++ is error-prone. Its grammar allows doing a lot of stupid things.

Below I collected some rules that help with writing scientific programs in C++. Some of them are actually required by the language, the others are just a good programming practice. I present them without much explanation on a shaman level [2]:

I prefer the term "shamanism" because this is not a high-level doctrine such as Cargo cult programming [3] or Voodoo programming [4]. The rules are not strict as Commandments [5] or Taboo [6]. For example, "Do not use" should be read "Avoid using". I also do not go so far as in [7].

Shaman's spells (in a random order):

Work in progress

References

  1. Scott Meyers. Effective C++: 50 Specific Ways to Improve Your Programs and Design, Addison-Wesley, 2007.
  2. Shamanism, From Wikipedia, the free encyclopedia.
  3. Cargo cult programming. http://en.wikipedia.org/wiki/Cargo_cult_programming .
  4. Voodoo programming. http://en.wikipedia.org/wiki/Voodoo_programming
  5. Commandments. http://en.wikipedia.org/wiki/Ten_Commandments
  6. Taboo.  http://en.wikipedia.org/wiki/Taboo
  7. Features To Avoid Like the Plague. http://www.cs.virginia.edu/~knabe/iic2332/c++/c++_5.html
  8. Copy Constructors. http://www.fredosaurus.com/notes-cpp/oop-condestructors/copyconstructors.html
  9. Linus Torvalds: Why C++ Sucks. http://advice.cio.com/esther_schindler/linus_torvalds_why_c_sucks
  10. Cargo Cult Science: http://wwwcdf.pd.infn.it/~loreti/science.html  or  http://en.wikipedia.org/wiki/Cargo_cult_science
Up ABC tutorials

Up: Scientific programming
Previous: Numerical objects
Next:  Project environment

Home | Resumé |  Shokhirev.com |  Computing |  Links Publications

©Nikolai V. Shokhirev, 2004-2008