Home > Articles > Programming > Java

An Interview with Alexander Stepanov and Paul McJones on Elements of Programming

Andrew Binstock interviews Alexander Stepanov and Paul McJones, the authors of The Elements of Programming, on their new book, decomposing software, why C++ was their choice for the book, and their perspectives on OO and generic programming.
Like this article? We recommend

Like this article? We recommend

Andrew Binstock: Alex, people know you for your work on the Standard Template Library (STL) in C++. I suspect most readers have not heard much about your subsequent work. Could you update us on what you’ve been doing?

Alexander Stepanov: I have been searching for principles to decompose software into components since the late 1970s. STL was an example of that. While intended to be a useful library, it was also intended as a model for others to build such components. After the STL became successful, I realized that people were using it without attempting to design their own software using the same principles. Fortunately I was given the opportunity at SGI to spend several years teaching very experienced compiler engineers these techniques. When I came to Adobe I was again asked to focus on teaching engineers (specifically Photoshop and the advanced graphics development team) these programming techniques. While not everyone liked the approach, many—I would even say the majority of engineers—told me that it changed their view of programming. It was rewarding for me that programmers with advanced degrees and years of experience were willing to attend the lectures and do challenging homework for a year or even more in addition to their busy product development schedule. Therefore when Adobe management suggested I write a book, it seemed a worthwhile undertaking.

Andrew: What are you currently working on at Adobe?

Alex: I’ve been teaching advanced programming classes and developing an overall curriculum for Adobe engineers. Now I’m in transition to a new role.

Andrew: Paul, I suspect you’ll be less familiar to readers than Alex. Your site, mcjones.org/paul, presents your long history of working with operating systems and language tools, especially Modula 2 and Modula 3. Can you fill that in a little and tell us how you came to be Alex’s co-author?

Paul McJones: After attending Alex’s course at Adobe for a few months, I realized that he was developing rigorous answers to questions about how to decompose software that had concerned me since I worked with John Backus in the mid 1970s on functional programming. It turns out that John’s work on FP was one of the major inspirations for Alex in the late 1970s. Alex’s original intuition was to associate specific functional forms (for example, reduction) with algebraic properties of specific functions (such as associativity). In retrospect, there are interesting parallels on the one hand between my conversations with John, and my earlier attempts to extend APL operators while working on an APL virtual machine at U.C. Berkeley, and on the other hand between Alex’s insights about John’s work, and with Alex’s discussion with Iverson about defining new operators. Thus it was an honor when Alex invited me to coauthor the book with him in early 2007. While I had no STL and little C++ experience before taking his course, my work specifying Modula-3 library interfaces gave me some confidence that I could contribute to the effort.

While Alex makes effective use of stories in his lectures, I was uncomfortable with the somewhat self-indulgent, conversational style in Alex’s written lecture notes. I advocated the impersonal style used in the mathematics and computer science books from my college courses in the 1960s. Alex quickly agreed, and we evolved a style that we both find appropriate.

Andrew: I see that in addition to being a co-author, you manage the collection of Alex’s papers. Is there a Boswellian element to your work with him? Do you work together on a regular basis at Adobe? If so, what do you work on together?

Paul: I have been interested in the history of software for some years. (See for example my collection of the original IBM 704 Fortran compiler at the Computer History Museum.) When I began attending the course Alex was teaching at Adobe, I became interested in how his work had evolved since the late 1970s, leading me to organize the Collected Papers web site. I learned from Alex’s lectures how his study of the history of mathematics, extending back to the Greeks and before, is integral to his view of mathematics and programming. So both of us could be called historically informed computer scientists. While we removed all the historical anecdotes that appear in Alex’s lectures, we still feel the book is grounded in thousands of years of mathematics and some 60 years of computer science history.

Andrew: What are you currently working on at Adobe?

Paul: Before Elements of Programming, I was one of the designers and implementers of Adobe’s Pixel Bender language. Now I too am in transition to a new role.

Andrew: Your new book, Elements of Programming, appears to be an attempt to map programming logic to principles of mathematics and formal logic and thereby establish the correctness of various code elements. Why did you write this book and what need does it fill?

Alex: We do not need to map programming to mathematics. Programming by its nature is a mathematical discipline, since programs manipulate abstract mathematical objects such as integers, shapes, sequences, etc.

Paul: We take well-known programs such as min and max, greatest common divisor, and binary search, and show their true mathematical settings. As mathematics helps mechanical engineers build bridges that do not collapse, mathematics helps programmers build dependable software.

Andrew: The book, while short, is a very difficult read and requires considerable a priori schooling in formal logic and abstract algebra. What benefit does a practitioner derive from working through it? How would a working programmer’s way of thinking change as a result of reading the book?

Alex: The book is difficult; there is no easy road to programming. Everything that goes beyond high school mathematics (elementary geometry and algebra) is defined in the book.

Paul: Working through the book teaches how to reason about code, how to find sets of useful interfaces, and how to design powerful and efficient components that can work together.

Andrew: Were you concerned that developers, even those with extensive computer science backgrounds, might be flummoxed by sentences such as “A discrete Archimedean semiring lacks additive inverses...” (p. 86). This quotation and others suggest that the real audience for this book is mathematicians rather than computer scientists. Whom do you have in mind as the intended reader?

Alex: As we say in the preface, the book must be read sequentially. Taken out of context that sentence might scare someone, but a reader will have previously learned that a semiring is a type combining addition and multiplication and that the Axiom of Archimedes allows division with remainder. While some mathematicians might benefit from the book as a way to learn about programming, the book is primarily targeted at programmers.

Paul: The evidence from the courses at SGI and Adobe is that determined programmers with computer science degrees can work through this material. But, yes, it does require an effort. On a personal note, I forgot the little abstract algebra I learned in college, but had no difficulty relearning the material.

Andrew: I am surprised that you did not include a glossary for these definitions. Do you not view this as a book that might be used for subsequent reference? Or should we infer from this aspect and from the exercises that you intended this to be primarily or exclusively used as a textbook?

Paul: Mathematicians have created a large taxonomy of concepts. The purpose of this book is to demonstrate how to adapt part of the taxonomy to organize software components. The book is not intended to be a reference book; for example, it does not define fields (such as reals), multidimensional structures, and stops just a bit short of defining Quicksort.

Alex: It is, as it were, a prolegomena to any future reference on software components.

Paul: And rather than a glossary, we have a detailed index.

Andrew: You say, “The purpose of this book is to demonstrate how to adapt part of the [mathematician’s] taxonomy to organize software components.” Of the many things one hears developers needing, organizing software components is not often listed. How is this need apparent? And how does this book answer that need?

Alex: A colleague of ours at a prominent software company recently reviewed a complex piece of code. He observed that it was equivalent to a call of find_if followed by a call of rotate; it took him a week to convince the other programmers of this equivalence. If those programmers had read our book they would recognize this fact.

Paul: In general, programmers should avoid inventing components or taxonomies, for that matter, but should recognize the well-known ones, just as mathematicians have been building on their predecessors’ work for centuries.

Andrew: Are the answers to the exercises available on-line? If so, where?

Alex: It might be valuable to have an edition containing proofs of all the lemmas and answers to all the exercises, but we do not have immediate plans to work on it.

Paul: Note that eop.h on the website has many additional algorithms mentioned in the text or assigned as exercises.

Andrew: In working on the code for the book, how did you test it?

Paul: First, we used “pair programming”; both of us read and reread every line of every program many times. Second, we wrote unit tests, which are available along with the code from the book on http://www.elementsofprogramming.com. We used gcov to check the coverage of our unit tests.

Alex: Sadly, we are sure there are still some undiscovered bugs. We keep the errata up-to-date on the web site.

AB: Paul, you’ve implemented several languages on several platforms. In this book, you and Alex chose C++ as it had the capabilities needed to demonstrate the techniques you were illustrating. What aspects of C++ made it your choice for this book?

Paul: The ability to overload functions and operator symbols allows us, when defining a particular concept, to specify the signatures of the operators and functions that must exist for any type modeling the concept. The ability to define new types with copy constructor, assignment, and equality modeling the regular concept means types defined by the programmer behave the same way as built-in types like int. The ability to pass arguments by reference means that we can work with regular types efficiently.

Alex: I’d like to remind you that C++ is not an object-oriented language, but a multi-paradigm language with features that supports object-oriented style of programming: inheritance and virtual functions. We don’t use these features. To summarize, we know how to say what we want in C++ but do not know how to say it in other languages. It helps that C++ is a language familiar to programmers at Adobe, where most products are implemented in it. Note, however, that the fundamental concepts we define come from mathematics, not from C++ or any other programming language.

Andrew: Alex, you’re known in part for your strong negative opinions about OO “I find OO technically unsound, methodologically wrong, etc.” Yet you still chose a subset of C++ for the code. Does this choice reflect any change in your feelings about OO?

Alex: The book is about programming as algorithms and data structures viewed as a mathematical activity, not about language techniques. A small subset of C++ that does not include any object-oriented features allowed us to say what we wanted. There are cases where object-oriented features are useful, but they are often oversold.

Paul: I should add I entered the project without extensive C++ experience, and found our subset to be natural and powerful.

Andrew: In the book, preconditions are integrated into many of the code snippets. The explicit use of preconditions is reminiscent of design by contract (DBC). Were you tempted at all to use a language such as Eiffel in which you could have stated pre- and post-conditions, as well as the “contract terms” or a Knuth-like solution of inventing your own language for purpose of illustrating code?

Paul: We spent a lot of effort on everything from selecting a small set of control statements, expressing pre- and post-conditions, and specifying the requirements (concepts) on the types used by an algorithm. We are happy with the result: a small subset of C++ extended with informal but consistent conventions for defining concepts and using them to specify type requirements. The code all compiles and runs; we find it quite readable.

Alex: While it is possible that in the future there will be a language that could better support this style of programming, we think that language design should follow, rather than precede, learning this style and applying it to components and programs. An appropriate programming language needs to be distilled from a large body of programs. But we do not need to wait for the creation of such a language. Scientists and engineers have been able to apply mathematics to physics, chemistry, civil engineering, and so on without creating a formal language. Instead, the informal but rigorous approach to definitions, theorems, and proofs used by mathematicians since Euclid provided a very solid foundation for many areas of science and engineering.

Andrew: Alex, the book, it seems, extends your work with generic programming using as illustration small, discrete algorithms. How would a developer use these techniques for attacking more-complex tasks?

Alex: First I need to clarify the term “generic programming.” Dave Musser and I introduced it in the late 1980s to mean a style of programming based on decomposing software into highly reusable and efficient components. Now, the term often signifies a set of techniques that are neither highly reusable nor efficient. Therefore, Paul and I decided not to use the term in the book. Moreover, both of us believe this is not just a style of programming, but programming as it must be: always trying to get to the essence of every algorithm.

A reader of the book will learn that even a task as simple as defining min and max is difficult—I got it wrong in STL, and nobody noticed! There are more difficult tasks than min and max, but the same reasoning applies to them. The book also demonstrates how to decompose complicated algorithms into simple steps.

Paul: Consider, for example, writing the two-line sort_n at the end of chapter 11 without any of the algorithms developed before that point.

Andrew: Is there a design-level equivalent to generic programming? That is, at the level of designing modules and their interaction?

Paul: We follow Wirth in believing that algorithms and data structures constitute the essence of programming. I haven’t seen any barriers to this approach.

Andrew Binstock is best known for his long-running column in SD Times and for his reviews in InfoWorld. Prior to his current work, he was head of Technology Forecasting for PricewaterhouseCoopers. Earlier he was the editor in chief of UNIX Review for many years, and previously founded the C Gazette. He is the co-author of “Practical Algorithms,” which went through 14 printings before becoming part of the long tail. When not writing, he’s a committer on the Platypus project, (http://platypus.pz.org) an open-source page-layout and typesetting package.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020