Programming

From Matt Morris Wiki
(Redirected from C++)
Jump to navigation Jump to search

Error Handling

See here: Errors

Methodology

See here: Methodology

Excel

Excel Tetris. Because you're worth it.

C++

Does Not Compute

90% of people I interview who describe themselves as expert C++ programmers don't know how to write code that handles resources correctly in the presence of exceptions. I have no idea why. The information has been on the web for free since before 2000.

Template Metaprogramming

I split C++ features into 3 classes:

  • useless/dangerous: eg, export keyword, throw specifications, uncaught_exception
  • significant downsides: eg, template metaprogramming
  • essential: eg, const, exceptions, inheritance

The downsides of template metaprogramming are:

  1. inconsistent compiler support across vendors (this is improving all the time though)
  2. a lack of compiler support for decent error messages (was being remedied as "concepts" in the next revision of C++, C++0x, but they've removed "concepts" now)
  3. a lack of compiler support for closures (being remedied as lambda functions in C++0x)
  4. a lack of compiler support for external templates ("export" is useless, again this is remedied in C++0x)
  5. a lack of standard library support for metaprogramming, particularly for type traits (again being remedied in C++0x)

I have seen the results of three attempts at different banks to introduce extensive templating into quant libraries using metaprogramming concepts that have failed for the reasons above - these are not theoretical concerns.

In the same way that a gentleman was once defined as "someone who can play the saxophone, but refrains from doing so", I'd regard a decent C++ programmer as someone who's read the literature on this (my own reading includes Josuttis/Vandevoorde. Abrahams/Gurtovoy, Alexandrescu, some of the older papers on expression templates) and then refrains from using template metaprogramming unless they have sufficient reason.