REVIEW - Generic Programming and the STL - Using and Extending the C++ Standard Template Library

Title:

Generic Programming and the STL - Using and Extending the C++ Standard Template Library

Author:

Matthew H. Austern

ISBN:

0201309564

Publisher:

Addison-Wesley Professional (1999)

Pages:

548pp

Reviewer:

Francis Glassborow

Reviewed:

April 1999

Rating:

★★★★★

I will just conclude by re-iterating my belief that this is the C++ programming book of 1998.

I have to confess to a certain amount of bias in my review of both this book and the next one ( Multi-Paradigm DESIGN for C++ ). In both cases I know the author and hold both of them in high regard for their technical expertise.

Matt Austern is a new comer to the world of book-authorship though he has honed his writing skills by writing articles for technical periodicals.

There could never have been any doubt about Matt's technical knowledge and after reading this book there could be no doubt about his writing skills. That already places him in a tiny elite writers who write well and know what they are writing about.

Many authors when the first write a book stick on safe terrain by writing for novices, or writing a typical academic book on algorithms and data structures. There is a sense in which this book might fit into the latter category but to describe it in those terms would be doing the author a grave injustice.

What he has done is to focus on a relatively new paradigm (of course we can trace the ancestry back a couple of decades) of generic programming. Just as Smalltalk focused programmers on the concepts of object-orientation, the development of the Standard Template Library in C++ has highlighted another way of writing programs. The ideas of generic programming are to concentrate on the underlying structure with as little regard for the exact types as possible. A second important idea is to separate data structures from the algorithms that work on them. In this way we can not only generalise for types but also for data structures. Lists, deques, vectors etc. share some properties while differing in others. Many programs will work with a choice of different containers. Containers themselves can use different resource allocation methods and so on. Generic programming works by abstracting commonality and encapsulating it in templates.

If we are to successfully decouple algorithms from data structures we need some form of glue to manage the interaction. This is provided via iterators and traits. Both these are families of related concepts. In the first part of this book Matt carefully explains the fundamental concepts and what their realisation in templates offer us. This part should be compulsory reading for all programmers who have stepped out of the nursery.

The second part of the book is a comprehensive description of the STL as it is today together with copious detail that will allow help you write your own extensions. Of course you will find numerous extensions in the text, such as hash-tables and adaptors to provide such things as hash_map.

I could go on but I will just conclude by re-iterating my belief that this is the C++ programming book of 1998. I doubt that any but the most expert of programmers could fail to benefit from reading this book (though you need to understand the basics of programming in general and the specifics of C++)


Book cover image courtesy of Open Library.