The D language, C++0x and threads
It's interesting to see our programming languages evolve, C++ is one of my favourites because it is so flexible for programming performance critical real-time apps like video games -- you really need to get as close to the metal as you can for speed, while the OO approach helps with modularity.
The question is how to improve our lot from what we have at present? I would like to see some compiler and developer environment improvements:
- Developer environments checking code as we type, just like my word processor does.
- Better static analysis at compile time, following through code pathways and warning about dead code (Some modules may be intractable).
- Verify that return values are handled when necessary, i.e. fopen() may return NULL, so code shouldn't just use the return value without checking if its valid.
- Likewise, there needs to be a language extension so the compiler can check the methods and functions which require their return value to be handled; how about a check keyword? (Not handling a returned pointer as above is the worst case which could cause a crash.)
- Compilers should check that C++ exceptions which may be thrown are handled.
C++0x will be finalised in the next few years. D is also available now, D is developed as an improved version of C++. It brings lots of interesting ideas, like multiple return args and the null keyword (C++0x will have nullptr I hope). Couldn't spot a pure keyword, would be handy for abstract bases will have this so they don't have to use =0 as at present! Maybe even some D ideas will pass back to C++0x. Would there ever be enough momentum to switch development to D? I don't think it is different enough from C++ for companies to want to make the shift.
I'd like to see a good system for managing memory pools in the standard library, perhaps Boost pool. OSs provide a good heap, but often fragmentation still happens. The heap doesn't know the expected lifetime of an allocation when it chooses where to place it. If a coder can help by separating their same-sized (or even smaller) objects to come from a pool that could help with performance.
Threads in C++ is still under discussion, Hans Boehm has proposed an idea, and Howard Hinnant of Apple has proposed something similar to Boost's thread mutex. Both are different from the pre-processor approach of OpenMP.
Interesting times ahead!
Labels: Coding