by rayiner · 13y ago · 0 comments
Moreover, because the various features are all fairly incompatible, you really have to think about how you want to design something before putting it down on paper. Were you passing around STL vectors of objects to take advantage of RAII? Well, hope you never want to create sub-classes and use polymorphic methods because then you'll have to change everything around to store pointers instead and change all your '.' indirections into '->' indirections. Oh wait but that fucks up your memory management, so you better change everything to use smart pointers and hope nobody ever memcpys the arrays instead of using std::copy.
C++ is a mish-mash of features that don't really work together. The only guiding principle I can really see is: "is it cheap to implement?"
C++'s true merit lies in its flexibility to evolve with the latest understanding of how to write good, abstract code with little runtime penalty, IMHO.
A really good example is libfirm versus llvm. The former is in C< the latter is in C++. They're both roughly the same order of magnitude in size (at least the core). They're both highly optimizing compilers. I find the former far more clear and readable.
I personally find C++'s abstractions to be of questionable value. YMMV.
Fun fact: A full build of libfirm is faster than LLVM's configure.
The compilation process is one of C++ greatest weaknesses. Since the iteration speed (change-compile-runtest) is a significant productivity factor, C can be more productive than C++. On the other hand, D shows that a language with a comparable feature set to C++ can be compiled much faster.
Llvm implements generic compilation with implementations for C, C++, Objective C, Objective C++, Ada, D, Fortran, Haskell, Java bytecode, CIL, MacRuby, Standard ML.
Of course there is a difference in complexity.
Libfirm (with liboo extension) does not support exceptions, but apart from that there should be little difference in features.
For example, there is an experimental frontend for Java bytecode [1]. It compiles ahead-of-time, like gcj.
[0] http://pp.info.uni-karlsruhe.de/uploads/publikationen/liebe1...