
From Mathematics to Generic Programming
by Alexander A. Stepanov, Daniel E. Rose · first published 2015
31mentions
12recommended by
22HN commenters
2014–2025first – last mentioned
55% recommend41% neutral5% critical
Why HN recommends it
Approachable path from a basic algorithm like multiplication to abstract implementations, explaining the math along the way (abstract algebra, number theory). Gentler than Elements of Programming; suits C++ programmers.
Summarised by Claude from recommending comments
A detailed, mathematically-oriented examination of abstraction in software development leading to concepts and techniques in generic programming.
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







I have not yet read "Elements of Programming," but there is another book "From Mathematics to Generic Programming," also co-authored by Alexander Stepanov, which links Abstract Algebra to program design. I found the latter very approachable: https://smile.amazon.com/Mathematics-Generic-Programming-Ale...
on “What Is Abstract Algebra? [video]” ↗I’m currently enjoying “From Mathematics to Generic Programming” by Alexander Stepanov and Daniel E. Rose. One thing about the book is that it’s a lot more interesting than what a cursory scan of the table of contents would suggest. An O(log n) algorithm for multiplication…
on “Ask HN: What is the best programming book you've read?” ↗…explains this really well by taking you from a basic algorithm to an abstract implementation, explaining the maths along the way (from multiplication to abstract algebra and number theory). It's titled From Mathematics to Generic Programming and I recommend it to anyone who wants to understand more of what I mean[2]. -- [1]: http://math.stackexchange.com/questions/165341/any-group-of-... [2]: http://www.amazon.com/Mathematics-Generic-Programming-Alexan...
on “Ask HN: What are some important math topics every programmer should know?” ↗…properly, you're well on your way to becoming a profiicent C++ programmer. His books are fantastic too. Elements of Programming: https://www.amazon.com/Elements-Programming-Alexander-Stepan... and From Mathematics to Generic Programming: https://www.amazon.com/Mathematics-Generic-Programming-Alexa... If you prefer video lectures, his second book is based off his lecture series Four (three) Algorithmic Journeys: https://www.youtube.com/playlist?list=PLHxtyCq_WDLV5N5zUCBCD...…
on “Ask HN: What is the best Modern C++ MOOC?” ↗That was kind of my impression, from the discussion in Alexander Stepanov and Daniel Rose's From Mathematics to Generic Programming (which is a pretty decent book, by the way). My understanding[1] is that concepts act like a type system for templates and like typeclasses in Haskell and traits in Rust. [1] http://maniagnosis.crsr.net/2015/07/abstracted-algebra-in-ru...
on “C++ concepts support merged into GCC trunk” ↗…E. Leiserson, Ronald L. Rivest, Clifford Stein. "The Garbage Collection Handbook: The Art of Automatic Memory Management" from Richard Jones and Antony Hosking "Code Complete" from Steve McConnell "From Mathematics to Generic Programming" from Alexander Stepanov and Daniel Rose
on “Ask HN: What language-agnostic programming books should I read?” ↗Many of them feature prominently in Stepanov's books, Elements of Programming and From Mathematics to Generic Programming. 'Elements' is a technical monograph, while the other is a more lightweight read, halfway between semi-pop-science and a textbook. There's also an old textbook by Birkhoff & Bartee called 'Modern Applied…
on “A Brief Guide to a Few Algebraic Structures” ↗From Mathematics to Generic Programming - Stepanov & Rose Gödel, Escher, Bach: an Eternal Golden Braid - Hofstadter Euclid's Elements
on “Ask HN: Math books that made you significantly better at math?” ↗Two books that did for me what I think you are looking for: - From Mathematics to Generic Programming by Stepanov & Rose - Gödel, Escher, Bach: an Eternal Golden Braid by Hofstadter - The Little Schemer / The Seasoned Schemer
on “Ask HN: Good books on philosophy of engineering?” ↗…constrained genericity. This flexibility is quite powerful and you get full type checking. To understand all this (and apply the concepts in any other language) see the books by Alexander Stepanov viz. From Mathematics to Generic Programming and Elements of Programming.
on “Liskov Substitution: The real meaning of inheritance” ↗…with Abstract Algebra/Discrete Mathematics is assumed. The mapping he does from the mathematics to a language construct modeling a concept is what gives one the insight into programming. His other book From Mathematics to Generic Programming gives one a more "easier" approach to the subject and should be read in conjunction with this one for better understanding. A related old book is Ruminations on C++: A Decade of Programming Insight and…
on “Elements of Programming (2009)” ↗Related book by Stepanov and Rose : From Mathematics to Generic Programming.
on “Quirky computing books” ↗…https://en.wikipedia.org/wiki/Mathematical_proof 2) Computer-assisted Proof - https://en.wikipedia.org/wiki/Computer-assisted_proof In particular; see the "Philosophical Objections" section. 3) See also the book From Mathematics to Generic Programming by Alexander Stepanov and Daniel Rose to get an idea of how to map between mathematics and programming.
on “Mathematics for Computer Science (2024)” ↗- Tour of C++ (http://www.stroustrup.com/Tour.html) - Principles and Practice Using C++ (http://www.stroustrup.com/programming.html) - From Mathematics to Generic Programming (http://www.fm2gp.com/) - The Scott Meyers books Some of the Bjarne Stroustrup videos, "Learning and Teaching Modern C++" - https://www.youtube.com/watch?v=fX2W3nNjJIo Some of the Herb Sutter videos,…
on “Ask HN: Best way to learn modern C++?” ↗This is a great book. This wasn't mentioned in the past thread. Alex presents his ideas in my forms. This one happens to be the most terse and mathematical. That can be good, but I think "From Mathematics to Generic Programming" is much more generally approachable. One practical skill that's shown well in this book is writing functions that solve the easiest or special cases, and then layering those into general functions which…
on “Elements of Programming (2019)” ↗