
A discipline of programming
by Edsger Wybe Dijkstra · first published 1976
51mentions
16recommended by
30HN commenters
2009–2025first – last mentioned
53% recommend47% neutral
Why HN recommends it
Introduces formal program derivation and correctness proofs for imperative programs, with worked examples on designing elegant algorithms. Suits programmers who want a mathematical grounding beyond testing.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.







That Paul Graham quote - “Programming languages are not merely technologies, but habits of mind as well.” Reminds me of an excellent Dijkstra quote, from A Discipline of Programming - "A most important, but also a most elusive, aspect of any tool is its influence on the habits of those who train themselves in its use."
on “Home at Last, or, The Last Programming Language I Will Ever Learn” ↗…Leo Brodie, Thinking FORTH W. H. Burge, Recursive Programming Techniques Carriero and Gelernter, How to Write Parallel Programs A. K. Dewdney, The New Turing Omnibus Edsger Dijkstra, A Discipline of Programming Richard Feynman, The Feynman Lectures on Computation Friedman and Felleisen, The Little Schemer Friedman and Wand and Haynes, Essentials of Programming Languages [1st edition] James F.…
on “Which programming book you just couldn’t stop reading from start to end?” ↗Dijkstra and Scholten's Predicate Calculus and Program Semantics is a good textbook on the subject. Dijkstra's a Discipline of Programming is much more informal, but I find it more readable and it has a number of good examples.
on “Proofs are Programs – 19th Century Logic and 21st Century Computing (2000) [pdf]” ↗It’s a wonderful book. The “sequel” Predicate Calculus and Program Semantics by Dijkstra and Scholten gives a more rigorous treatment of the ideas presented in A Discipline of Programming. Both are fantastic.
on “A bestiary of single-file implementations of programming languages” ↗…mode that only allows edits that preserve the given invariants, perhaps using TLA+ or something similar. Anyone that wants to learn more on the subject of deriving programs should read one or both of A Discipline of Programming[1] and Predicate Calculus and Program Semantics[2]. The former is more approachable for the programmer who isn't as inclined toward formal mathematics. The latter basically takes the same concepts and…
on “A commemoration of Edsger Dijkstra [pdf]” ↗…might be used. Since any given predicate transformer has a syntactic representation, the result is the program text. As you can see the result is correct by construction. I recommend reading Dijkstra’s A Discipline of Programming for pragmatic examples of using predicate transformers to derive correct programs. If you want a more rigorously formal treatment of the same subject there’s Dijkstra and Scholten’s Predicate Transformers…
on “Make formal verification and provably correct software practical and mainstream” ↗Dijkstra’s A Discipline of Programming and its spiritual successor that he did with Scholten Predicate Calculus and Program Semantics. They changed how I think about programming.
on “Ask HN: Which books do you consider real gems in your field of work/study?” ↗…rather hypothetical use of the word "easier." Is it possible that one day this will actually be easier? Sure. Is this the case now? I don't think so. Respectfully, I recommend that you read Dijkstra's A Discipline of Programming that I linked above. I think you'll find it interesting at the very least and possibly even enlightening. I assume you are a product of the American educational system, where these concepts are rarely…
on “Using TLA+ in the Real World to Understand a Glibc Bug” ↗…that does that." Well, as pointed out by others, TDD doesn't actually prove that. There are however methods that do, which fall under the general heading of formal methods or program proof. Read "A Discipline of Programming" by Dijkstra for a reasonable introduction. The techniques work, but are laborious. Modern theorem provers can help, but it still involves considerable effort. Which implies that such methods likely won't…
on “Problems with TDD” ↗…using any programming language and that programming language tutorials fail to discuss. You can see a preview at Google Books: http://books.google.ca/books?id=vv5pot-ySsEC&lpg=PP1&... There's also A Discipline of Programming by Dijkstra and I love that one too. He has examples of great algorithms and the way he develops them is awesome: http://www.amazon.com/Discipline-Programming-Edsger-W-Dijkst... The reason books like…
on “Ask HN: Programming books that are more like math books?” ↗I agree. I would place Dijkstra's 'A Discipline of Programming' and Feijen and van Gasteren's 'A method of multi-programming' right up there with 'Introduction to Algorithms'. What sets these books apart is that they try to tackle the problem of _how_ to design…
on “What is the single most influential book every programmer should read?” ↗…Pascal by Kernighan and Plauger. - Programming Pearls by Bentley - Smalltalk 80: The Language and Its Implementation by Adele Goldberg. - Paradigms of Artificial Intelligence Programming by Norvig - A Discipline of Programming by Dijkstra While I've ommited some important language specific books, and ignored essential areas (algorithms, discrete math, hw arquitecture), I think this is a good starting point.
on “Codeacademy for competent programmers?” ↗Try "A Discipline of Programming" and "Structured Programming" by Edsger Dijkstra (the second with co-authors C. A. R. Hoare & Ole-Johan Dahl). Also, Project Oberon by Niklaus Wirth, for showing how it can be done well and clearly.…
on “Ask HN: Are there any resources to learn how to think about programming?” ↗Also see - "A Discipline of Programming" by Edsger W. Dijkstra http://www.amazon.com/Discipline-Programming-Edsger-W-Dijkst...
on “Teach Yourself Programming in Ten Years (1998)” ↗…of my professors were pupils of Dijkstra and they were quite particular about formal verification as you can imagine) so that helps; it's good for anyone with an interest in this to read books like 'A discipline of programming' by Dijkstra or more modern books about it (and if you really like it, continue on to Pierce who is the types guy and when I read his some of his work the first time I kind of wondered wth we were doing…
on “The Case for Formal Verification (2013)” ↗