Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
From mathematics to generic programming
Stepanov A., Rose D., Addison-Wesley Professional, Upper Saddle River, NJ, 2015. 320 pp. Type: Book (978-0-321942-04-3)
Date Reviewed: Jan 22 2015

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 [1], 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.

On the code side of things, there is probably a lot less code than mathematics. The author uses C++ as the language of choice, but the code is concise enough that it should be readable and comprehensive to anyone who has experience in other languages such as Python, JavaScript, or Java (although users of more dynamically typed languages may wonder what all the fuss is about).

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

Reviewer:  Martin Schweitzer Review #: CR143104 (1505-0330)
1) Stepanov, A.; interview by Lo Russo, G. An interview with A. Stepanov. (Accessed 01/22/2015).
Bookmark and Share
General (D.0 )
General (D.2.0 )
General (G.0 )
Would you recommend this review?
Other reviews under "General": Date

Flanagan D. (ed)Type: Journal
May 1 1985
How to tell it what to do? The user talks to the machine
Snell F., Computer Science Press, Inc., New York, NY, 1987. Type: Book (9789780881750805)
Nov 1 1987
Brenton T., Howson M., Holt, Rinehart & Winston, Austin, TX, 1986. Type: Book (9789780030049989)
Oct 1 1987

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy