I first started programming in C++ in the early 1990s. At that stage, C++ was a better C. C++, or C with objects as it was known in its earliest days, has always supported object-oriented programming. However, it was only later that support for templates (or generic programming) came to C++. For me and many others, generic programming was only an interesting language feature, not a major new way of programming. Then, in the mid 1990s, a new library appeared called the Standard Template Library (STL), written by Alexander Stepanov and Meng Lee. All of a sudden, there was a whole new way to program, and for me at least, a much better way to compose programs. From the start, STL had an elegant design and offered the trinity of algorithms, iterators, and containers.
Reading about Stepanov, and in particular one interview with Graziano Lo Russo , made two things very clear: (1) Stepanov is a very bright person, and (2) he brought his very strong mathematical background to bear on the design of STL.
When I started reading this book, I expected at most half of it to be on mathematics and then the rest to be all about generic programming. Instead, I was pleasantly surprised. This book is mostly about mathematics and a lot about generic programming. The book focuses mainly on number theory and abstract algebra. It starts near the beginning a few thousand years ago and proceeds mostly in chronological order. Each chapter, roughly, introduces a new concept and talks about the mathematician who influenced it. So, there is a chapter on Greek number theory and Pythagoras, Euclid’s algorithm and Euclid (the chapter also mentions Plato and Leonardo Pisano, also known as Fibonacci). It then moves on to modern number theory, discussing Fermat and Euler. As each new mathematician is introduced, a short vignette gives some context to their lives and their work. Most of these mathematicians should be familiar to most people who have studied mathematics and number theory. I have to admit, though, that I had not previously come across Emmy Noether.
All the mathematics is very accessible to a person with a reasonable background in math. I have previously done courses at the university level in number theory, and so found most of the material familiar. It’s difficult to say how hard it would be for someone with no previous exposure, but I suspect that s/he should be fine. There are a few sections where the author says there is some advanced math ahead and the reader should feel free to skip it. Of course, I read these sections, and they should be fine for most people with some mathematics background.
The examples focus on code for finding the greatest common divisor (GCD). This example runs through several chapters and illustrates how a generic approach leads to better code. It also illustrates the analogies between generic code with its “concepts” and “traits,” and abstract algebra with its “groups” and “rings.”
While I enjoyed this book tremendously and learned a lot from it, mostly about taking an idea and abstracting it mercilessly, I am not quite sure of the audience. I think that programmers with little interest in math may find it too mathematical, and people interested in math may not get the programming. There exists a group of people who will find this book very enlightening. The book could possibly be used in a computing course--there are some exercises, but not enough to suggest that the book was conceived as a textbook.
Given the title, a prospective reader may wonder: Will I be a better programmer after reading this book? The answer for me was yes.
More reviews about this item: Amazon, Goodreads, i-Programmer