Looking at Effective C++

Introduction

July 25, 2005

By
Ibrahim Haddad

The first two editions of Effective C++ were embraced by hundreds of thousands of programmers worldwide. The reason is clear: Scott Meyers' practical approach to C++ describes the rules of thumb used by the experts--the things they almost always do or almost always avoid doing--to produce clear, correct, efficient code.

The book is organized around 55 specific guidelines, each of which describes a way to write better C++. Each is backed by concrete examples. For this third edition, more than half the content is new, including added chapters on managing resources and using templates. Topics from the second edition have been extensively revised to reflect modern design considerations, including exceptions, design patterns, and multithreading.

The third edition of Scott Meyers' classic Effective C++ was published in May, so we caught up with Scott to talk about his view of the the current C++ computing landscape.

LinuxPlanet: In your book you discuss the many changes that have occurred in the C++ universe since 1991. When it comes to C++ as a language, what do you see as the most significant change in the past decade?

Scott Meyers: There is no doubt that the most significant change has been what we might call "the rise of templates." Templates were originally envisioned as a
way to support "containers of T," but we now recognize that they are
vastly more powerful than that. The STL, the notion of generic
programming, policy-based design, template metaprogramming, and
expression templates are all technologies that have proved their
practical worth and that require template capabilities beyond containers
of T. All modern C++ libraries take advantage of the power of templates,
and in fact the notion of "modern" C++ programming is virtually
synonymous with programming that makes liberal use of templates. That's
why the new edition of Effective C++ not only contains a chapter devoted
to templates, it also mentions them throughout the book. You can't
be an effective C++ programmer these days without having a good
understanding of how to use templates.

LP: Are there any other changes that are as pervasive as the rise of templates?

Meyers: The other big change concerns the impact of exceptions on well-designed
and well-implemented software systems. When exceptions were first
introduced into C++, most people thought that their use was pretty
straightforward and that the main issue was learning how to master the
syntax and language rules. In fact, the syntax and language rules turn
out to be rather unimportant. What was unanticipated--what took years
to really understand--is that software that is well-behaved in the
presence of exceptions looks quite different from software that doesn't
worry about exceptions. Fortunately, there is a small core of techniques
that make writing exception-safe code more or less straightforward, and
those techniques are referred to repeatedly in the new edition of
Effective C++. The most important of the techniques is to use objects to
manage resources, a topic I devote most of a chapter to.