Elements of Programming

Hardcover (Print)
Buy New
Buy New from BN.com
Used and New from Other Sellers
Used and New from Other Sellers
from $15.47
Usually ships in 1-2 business days
(Save 61%)
Other sellers (Hardcover)
  • All (11) from $15.47   
  • New (5) from $28.78   
  • Used (6) from $15.47   


“Ask a mechanical, structural, or electrical engineer how far they would get without a heavy reliance on a firm mathematical foundation, and they will tell you, ‘not far.’ Yet so-called software engineers often practice their art with little or no idea of the mathematical underpinnings of what they are doing. And then we wonder why software is notorious for being delivered late and full of bugs, while other engineers routinely deliver finished bridges, automobiles, electrical appliances, etc., on time and with only minor defects. This book sets out to redress this imbalance. Members of my advanced development team at Adobe who took the course based on the same material all benefited greatly from the time invested. It may appear as a highly technical text intended only for computer scientists, but it should be required reading for all practicing software engineers.”
—Martin Newell, Adobe Fellow

“The book contains some of the most beautiful code I have ever seen.”
—Bjarne Stroustrup, Designer of C++

“I am happy to see the content of Alex’s course, the development and teaching of which I strongly supported as the CTO of Silicon Graphics, now available to all programmers in this elegant little book.”
—Forest Baskett, General Partner, New Enterprise Associates

“Paul’s patience and architectural experience helped to organize Alex’s mathematical approach into a tightly-structured edifice—an impressive feat!”
—Robert W. Taylor, Founder of Xerox PARC CSL and DEC Systems Research Center

Elements of Programming provides a different understanding of programming than is presented elsewhere. Its major premise is that practical programming, like other areas of science and engineering,must be based on a solid mathematical foundation. The book shows that algorithms implemented in a real programming language, such as C++, can operate in the most general mathematical setting. For example, the fast exponentiation algorithm is defined to work with any associative operation. Using abstract algorithms leads to efficient, reliable, secure, and economical software.

This is not an easy book. Nor is it a compilation of tips and tricks for incremental improvements in your programming skills. The book’s value is more fundamental and, ultimately, more critical for insight into programming. To benefit fully, you will need to work through it from beginning to end, reading the code, proving the lemmas, and doing the exercises. When finished, you will see how the application of the deductive method to your programs assures that your system’s software components will work together and behave as they must.

The book presents a number of algorithms and requirements for types on which they are defined. The code for these descriptions—also available on the Web—is written in a small subset of C++ meant to be accessible to any experienced programmer. This subset is defined in a special language appendix coauthored by Sean Parent and Bjarne Stroustrup.

Whether you are a software developer, or any other professional for whom programming is an important activity, or a committed student, you will come to understand what the book’s experienced authors have been teaching and demonstrating for years—that mathematics is good for programming, and that theory is good for practice.

Read More Show Less

Product Details

  • ISBN-13: 9780321635372
  • Publisher: Addison-Wesley
  • Publication date: 6/23/2009
  • Edition description: New Edition
  • Pages: 262
  • Sales rank: 792,501
  • Product dimensions: 6.40 (w) x 9.10 (h) x 1.00 (d)

Meet the Author

Alexander Stepanov studied mathematics at Moscow State University from 1967 to 1972. He has been programming since 1972: first in the Soviet Union and, after emigrating in 1977, in the United States. He has programmed operating systems, programming tools, compilers, and libraries. His work on foundations of programming has been supported by GE, Brooklyn Polytechnic, AT&T,HP, SGI, and, since 2002, Adobe. In 1995 he received the Dr. Dobb’s Journal Excellence in Programming Award for the design of the C++ Standard Template Library.

Paul McJones studied engineering mathematics at the University of California, Berkeley, from 1967 to 1971. He has been programming since 1967 in the areas of operating systems, programming environments, transaction processing systems, and enterprise and consumer applications. He has been employed by the University of California, IBM, Xerox, Tandem, DEC, and, since 2003, Adobe. In 1982 he and his coauthors received the ACM Programming Systems and Languages Paper Award for their paper “The Recovery Manager of the System R Database Manager.”

Read More Show Less

Table of Contents

Preface ix About the Authors xiii

Chapter 1: Foundations 1
1.1 Categories of Ideas: Entity, Species, Genus 1
1.2 Values 2
1.3 Objects 4
1.4 Procedures 6
1.5 Regular Types 6
1.6 Regular Procedures 8
1.7 Concepts 10
1.8 Conclusions 14

Chapter 2: Transformations and Their Orbits 15
2.1 Transformations 15
2.2 Orbits 18
2.3 Collision Point 21
2.4 Measuring Orbit Sizes 27
2.5 Actions 28
2.6 Conclusions 29

Chapter 3: Associative Operations 31
3.1 Associativity 31
3.2 Computing Powers 33
3.3 Program Transformations 35
3.4 Special-Case Procedures 39
3.5 Parameterizing Algorithms 42
3.6 Linear Recurrences 43
3.7 Accumulation Procedures 46
3.8 Conclusions 47

Chapter 4: Linear Orderings 49
4.1 Classification of Relations 49
4.2 Total and Weak Orderings 51
4.3 Order Selection 52
4.4 Natural Total Ordering 61
4.5 Clusters of Derived Procedures 62
4.6 Extending Order-Selection Procedures 63
4.7 Conclusions 63

Chapter 5: Ordered Algebraic Structures 65
5.1 Basic Algebraic Structures 65
5.2 Ordered Algebraic Structures 70
5.3 Remainder 71
5.4 Greatest Common Divisor 76
5.5 Generalizing gcd 79
5.6 Stein gcd 81
5.7 Quotient 81
5.8 Quotient and Remainder for Negative Quantities 83
5.9 Concepts and Their Models 85
5.10 Computer Integer Types 87
5.11 Conclusions 88

Chapter 6: Iterators 89
6.1 Readability 89
6.2 Iterators 90
6.3 Ranges 92
6.4 Readable Ranges 95
6.5 Increasing Ranges 103
6.6 Forward Iterators 106
6.7 Indexed Iterators 110
6.8 Bidirectional Iterators 111
6.9 Random-Access Iterators 113
6.10 Conclusions 114

Chapter 7: Coordinate Structures 115
7.1 Bifurcate Coordinates 115
7.2 Bidirectional Bifurcate Coordinates 119
7.3 Coordinate Structures 124
7.4 Isomorphism, Equivalence, and Ordering 124
7.5 Conclusions 131

Chapter 8: Coordinates with Mutable Successors 133
8.1 Linked Iterators 133
8.2 Link Rearrangements 134
8.3 Applications of Link Rearrangements 140
8.4 Linked Bifurcate Coordinates 143
8.5 Conclusions 148

Chapter 9: Copying 149
9.1 Writability 149
9.2 Position-Based Copying 151
9.3 Predicate-Based Copying 157
9.4 Swapping Ranges 164
9.5 Conclusions 168

Chapter 10: Rearrangements 169
10.1 Permutations 169
10.2 Rearrangements 172
10.3 Reverse Algorithms 174
10.4 Rotate Algorithms 178
10.5 Algorithm Selection 186
10.6 Conclusions 189

Chapter 11: Partition and Merging 191
11.1 Partition 191
11.2 Balanced Reduction 198
11.3 Merging 202
11.4 Conclusions 208

Chapter 12: Composite Objects 209
12.1 Simple Composite Objects 209
12.2 Dynamic Sequences 216
12.3 Underlying Type 222
12.4 Conclusions 225

Afterword 227

Appendix A: Mathematical Notation 231

Appendix B: Programming Language 233
B.1 Language Definition 233
B.2 Macros and Trait Structures 240

Bibliography 243
Index 247

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)