Modern Cee Plus Plus Design

"Modern C++ Design" by Andrei Alexandrescu (ISBN:0201704315)


See www.moderncppdesign.com One of the books in the Cpp In Depth Series published by Addison Wesley.


"Mandatory" book for the following categories:

C++ programmers (obviously).

C++ naysayers:
to make sure you're talking about the same C++ as C++ programmers do.

Java programmers (see what you've been missing all along).


I haven't finished reading it yet, but it seems to be re-inventing well-known OO concepts in C++ at compile-time instead of run-time. It seems like a big waste of a programmer's time to use template meta programming to do stuff that could be done easily in Smalltalk via polymorphism, dynamic dispatch, etc.

That's nice, but this is a book on how to do these things in C++, and in ways that trade a compile-time processing cost for a reduction in run-time cost. So what if another language can do them at run-time? If a programmer has other reasons for using C++, then why would it be a waste of time to learn how to do these things in C++?

Another take: The book tells you how to use C++ to implement well-known OO concepts. That sounds nice to me -- I'd like a book that explains how to do OO programming in C++!


What's more interesting to me is how Lisp-like much of the techniques are. C++ templates are very much like a Functional Programming Language, so many of the techiques look a lot like reimplementing Lisp features using the template features of C++. Perhaps it's Greenspuns Tenth Rule Of Programming. The disheartening thing to me (as a C++ programmer and non-Smug Lisp Weenie) is how baroque the implementation has to be, mostly because of Static Typing.


The first chapter of this book is called Policy Based Class Design and what is surprising to me is that there is not yet a page on Wiki Wiki for this topic. The book also introduced a library called Loki which implements a lot of interesting things. Some of these are also available in different forms in the Boost Libraries.

Generic versions of Visitor Pattern and Acyclic Visitor are discussed in Chapter 10 and implemented in Loki.



See original on c2.com