Shop now Shop now Shop now  Up to 50% Off Fashion  Shop all Amazon Fashion Cloud Drive Photos Shop now Learn More Shop now Shop now Shop Fire Shop Kindle Listen with Prime Shop now Shop now

Customer Reviews

4.4 out of 5 stars9
4.4 out of 5 stars
5 star
7
4 star
1
3 star
0
2 star
0
1 star
1
Your rating(Clear)Rate this item


There was a problem filtering reviews right now. Please try again later.

on 2 March 2007
This is 300 pages of the hardest of hardcore template metaprogramming you could currently hope to read. As a result, there is a risk you may find more to admire and speculate upon from afar, than to actually use. Various factors will decide this, from the robustness of your compiler, your comfort with far-out template wackiness, and your confidence in debugging and maintaining the result.

One thing is not in doubt: C++ metaprogramming is devilishly clever. That's part of its appeal. It's also capable of producing flexible, efficient families of software. Modern C++ Design pushes the boundaries of TMP further than the more specialised matrix domain detailed in Czarnecki and Eisenecker's Generative Programming (a recommended prologue to this book). Here, the aim is implementing entire design patterns. This is a fairly bold claim, as the received wisdom on design patterns is that there isn't a canonical form that can be presented in code.

And that still holds true. Instead, the code in Modern C++ Design is metacode built on two big ideas: policies and typelists, which are described in the opening chapters, along with some other useful tools. The hard intellectual work is done here, especially the typelist chapter, although previous exposure to the likes of Generative Programming definitely softens the blow. Policies are what Java programmers know as Dependency Injection, except one level of abstraction up (the relationship between classes and objects in DI is done with templates and classes with policies), and with the template instantiation and specialisation rules of C++ providing an extra layer of flexibility. Typelists are exactly as the name suggests - a list of types, but they exist only at compile time. They're fed to the TMP machinery, which spits out a class hierarchy based on the supplied list.

With these tools in place, Andrei Alexandrescu then proceeds to show how they can be used to work some magic. Template versions of the command, visitor, abstract factory and factory method patterns are presented, along with other abstractions like smart pointers (perhaps the most orthodox chapter of the book), tuples, and multiple dispatch.

The latter topic provides a connection to James Coplien's Advanced C++, which also discussed multimethods, albeit before templates entered the language. The books share a certain similarity, not so much in content, but in the spirit of stretching the boundaries of C++, and perhaps also in stretching its readability and maintainability.

For all the virtuosity on display here (and in Coplien's book), I'm not sure if I'd to use these techniques in my own C++. This may just be down to my own mediocrity as a programmer, but TMP is more than just an idiomatic application of C++, it's really an entirely new language and not a very friendly one. When encoding error messages into class names is a best practice, you know you're pushing the envelope.

There's no discussion in this book of where these designs are appropriate - I suspect the most rococo code will end up hidden safely behind frameworks and libraries such as the Loki library described in this book. Some discussion of these bigger picture strategic and cultural issues would have been handy, otherwise, a title like 'Modern C++ Design' suggests that herein lie techniques to sprinkle liberally throughout your code, and I suspect that this is not the case.

If you, your co-workers, and any customers that need to look at your code are all template metagenii, this is going to be the most productive 300 pages you ever read. Lesser mortals will find much to wonder at and admire, and a whole new perspective on design patterns, but perhaps less to put into practice.
0Comment|20 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 27 March 2001
Every couple of years there appears a classic, Stroustrupp, Advanced C++, the GOF patterns book, Eff C++ and More Eff C++, now there is this. Everyone has an opinion, and mine is this. Modern C++ Design is top of the list. It deserves to be no more than an arms length away from every serious programmer, designer, academic or teacher. Inside this you will find breath-taking displays of sheer wizardry, creativity, and inventiveness from a master craftsman. If I were to single out my favourite features of this book it would have to be the following, and don't be put off if you don't know what they are, just accept it that they are astonishing programming techniques and design tools. Policy classes. An astonishingly simple but elegant programming technique that enforces design time decisions completely. Typelists and a family of algorithms for manipulating them. Simply astonishingly, jaw-droppingly elegant structures for manipulating lists of types. The best description, and certainly the best implementation, of some of the GOF patterns I have ever seen. Have you read the consequences of a pattern and just singled in on one item which is exactly what you need. Then in another project, you can't use that implementation because you need to implement a different feature. E.g., single threaded in one project and multi-threaded in another or creating objects on the stack and then needing to use the heap. These implementations show you how to do all this, and more, in one suite of code. The Abstract Factory and Multi Method chapters are quite simply astonishing feats of engineering. It contains the best description of smart pointers I have ever seen. Ever wondered why std::string does not convert to a const char* but other string classes do?. Ever tried to write no-intrusive pre and post conditions. Read this chapter. Finally, it comes with a down loadable library of code (Loki) that is worth the price of the book alone. I expect that very soon, the word Loki will be as much a part of the C++ programmers language as STL
0Comment|69 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 4 April 2002
This is an excellent book, well written well structured and very interesting. The Library and the techniques described may not be of every day use but on those occasions when they are of use they would be very handy to have. The one problem is that these are advanced techniques and a lot of compilers (specifically Visual C++ 6/7) can't currently build the code. It is possible to rewrite the library to get around the compiler issues but it's a lot of extra work. That aside, compilers will be coming online that can use it soon so it is worth reading now in order to be able to start using it as soon as possible.
0Comment|11 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 13 March 2008
An excellent book and a IMHO a MUST if you want to get a professional C++ (and not only) developer.
It covers lots of practical topics, unveiling advanced techniques and "hidden" features of the C++ programming language.

I would suggest to get a good knowledge of C++ first (e.g. read Stroustrup's TCPL bible) or you won't grasp most of the topics.

I must admit that reading the book I was all "Wow! You can do that?!?".
Sure, not a big deal if you are already a pro, but you won't be reading this review, I suppose.

I would suggest this book even if you intend to move to another language as it really helped me thinking about things and understanding many language features and hardcore techniques.
0Comment|One person found this helpful. Was this review helpful to you?YesNoReport abuse
on 30 June 2013
This book is about template metaprogramming. Even if you can't see a use for that technique, merely reading this book will tax your brain to the maximum and expand your programming horizons.

I first read this book about a decade ago as some light (ahem) holiday reading and I'll be the first to confess that I didn't 'get it' first time. There were many 'how the ...?' and 'what the ...?' moments. Now a decade and a lot more experience later I've re-read it and finally it makes sense.

Andrei taxes the language and the compilers to the maximum in ways that you may not want to do in production code as the number of people that will be able to maintain it will be small, but as an intellectual exercise this book should be up there with Knuth's classics.
0Comment|Was this review helpful to you?YesNoReport abuse
on 19 February 2015
Do you need to write C++ that no-one else on your team will understand? Do you want to know areas of C++ even the compilers think twice about? Then this book is perfect for you!

In all seriousness, the book introduces generic programming and template metaprogramming. The concepts of policy-based design are made clear with relevant examples throughout the book. This is a C++ classic that all should read.
0Comment|Was this review helpful to you?YesNoReport abuse
on 27 January 2010
Modern C++ Design builds on some of the ideas presented in the classic Design Patterns book, and attempts to improve them specifically for C++. The examples fail to make a case for preferring Alexandrescu's patterns over the originals or other alternatives - while they are a clever use (some would say misuse) of templates, they result in unreadable, unmaintainable code. It's therefore quite disconcerting to see this book receive a number of glowing, uncritical reviews. Loki (the library that is described in the book), has not become a common tool for C++ programmers in the years since 2001 when one of the reviews on this page predicted it would. Instead, C++ programmers, compiler writers and standards committees have struggled to make templates usable for anything more than "containers of x". Perhaps that's where the experimentation should have ended, and we may have got an elegant library rather than the half baked Standard Template Library we have now.
0Comment|11 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 18 February 2005
Despite the advanced concepts covered the book is very well written and quite readable, but it does require you to think! I was using concepts in this book in my applications almost immediately. 10/10
0Comment|4 people found this helpful. Was this review helpful to you?YesNoReport abuse
on 17 July 2001
This is a fantastic book. It's concise. It's precise. It contains many advances C++ idioms you would never have thought possible.
0Comment|6 people found this helpful. Was this review helpful to you?YesNoReport abuse

Sponsored Links

  (What is this?)