About this book
Structured Programming was published by Academic Press in 1972. It is a modest-looking book with an unusual make-up. It is not a single treatise but three long essays, each a small book in itself, written by three of the people who did most to turn programming from a craft into a discipline. Edsger W. Dijkstra contributed Notes on Structured Programming. C. A. R. Hoare contributed Notes on Data Structuring. Ole-Johan Dahl and Hoare together contributed Hierarchical Program Structures, an account of the ideas behind the Simula 67 language.
The book appeared at a particular moment. By the late 1960s computers had become powerful enough to run very large programs, and those programs were failing. Operating systems shipped late and full of errors. Projects ran years over schedule. In 1968 a conference sponsored by NATO in Garmisch, Germany, gave the problem a name, the software crisis, and popularised the phrase software engineering as a hoped-for remedy. People who wrote programs had begun to realise that their methods did not scale. A program twice as large was not twice as hard to get right; it was far harder.
The three essays answer that crisis from three directions. Dijkstra asks how a program should be designed so that a human mind can understand it and be confident that it is correct. Hoare asks how the data a program handles should be described and organised, with the same care usually given only to its instructions. Dahl and Hoare ask how a large program can be built out of parts that each package data together with the operations on it, so that the whole can be understood one layer at a time.
The audience was programmers and researchers in the early 1970s: people who knew languages such as ALGOL 60, FORTRAN and assembly code, who had written real programs and seen them fail. The essays assume this experience. They are not tutorials. They are arguments, illustrated with worked examples, about how the practice of programming ought to change.
The shelf note puts the shared aim in a line: programs built so a person can reason about them. That sentence is the thread through all three essays. Each author takes for granted that the main limit on programming is not the speed of the machine but the capacity of the human mind, and each proposes a way of working within that limit.
It is worth saying what the title meant then and what it means now. Today structured programming is often reduced to a slogan: avoid the goto statement and use loops and conditionals instead. That rule is part of Dijkstra's argument, but only a small part. The book's real subject is the organisation of thought. Control structures, data types and classes are the tools; the goal is a program whose shape mirrors the reasoning that justifies it.
The authors
Edsger W. Dijkstra
Edsger Wybe Dijkstra was born in Rotterdam in 1930. He studied theoretical physics at Leiden and in the early 1950s began working as a programmer at the Mathematical Centre in Amsterdam, at a time when, as he later recalled, programming was not recognised as a profession at all. He chose it anyway. In the late 1950s he published a short, elegant algorithm for finding shortest paths in a graph, still taught everywhere under his name. With Jaap Zonneveld he wrote one of the first compilers for ALGOL 60, a language whose clean design shaped all of his later thought.
In the 1960s, as a professor at the Technological University of Eindhoven, he led the design of the THE multiprogramming system, an operating system organised as a strict hierarchy of layers, each relying only on the ones below. For it he invented the semaphore, a basic tool for coordinating processes that run at the same time. The experience of building THE, and of making it work reliably, underlies much of his notes in this book. In 1968 his short letter against the goto statement, published under the editor's title Go To Statement Considered Harmful, made him famous and controversial.
Dijkstra received the Turing Award in 1972, the year this book appeared. His award lecture, The Humble Programmer, argued that programmers must accept the limits of their own minds and design accordingly. He later worked as a research fellow for the Burroughs Corporation and from 1984 taught at the University of Texas at Austin. He wrote a long series of handwritten notes, numbered and circulated among colleagues, which remain a remarkable record of a mind at work. His book A Discipline of Programming, in 1976, developed the ideas of this essay into a formal calculus for deriving programs. He died in 2002.
C. A. R. Hoare
Charles Antony Richard Hoare, known as Tony Hoare, was born in 1934 in Colombo, Ceylon, now Sri Lanka, to British parents. He studied classics and philosophy at Oxford, learned Russian during national service, and went to Moscow State University to work on machine translation. There he devised Quicksort, the sorting method that is still among the most widely used. Back in Britain he worked for the computer maker Elliott Brothers, where he led the implementation of an ALGOL 60 compiler and learned, through a failed large project, how badly software could go wrong.
In the mid-1960s he proposed a scheme for handling records, groups of related data items accessed through references, and his ideas fed directly into Simula 67 and into the language ALGOL W that he designed with Niklaus Wirth. He moved to Queen's University Belfast in 1968 and to Oxford in 1977. In 1969 he published a paper giving an axiomatic basis for computer programming, introducing what is now called Hoare logic, a formal system for proving programs correct. He later developed monitors for concurrent programming and the theory of Communicating Sequential Processes. He received the Turing Award in 1980.
Ole-Johan Dahl
Ole-Johan Dahl was born in Norway in 1931. He worked at the Norwegian Defence Research Establishment, where he gained deep experience in programming early machines, and then at the Norwegian Computing Center in Oslo. There, with Kristen Nygaard, he designed Simula, first as a language for writing simulations and then, in the 1967 version, as a general-purpose language built around the idea of classes and objects. In 1968 he became a professor of informatics at the University of Oslo.
Dahl and Nygaard together received the Turing Award for 2001 for the ideas that underlie object-oriented programming. Both died in 2002, within weeks of each other. Dahl's contribution to this book is the most direct account of Simula 67 written for a general audience of programmers, and it shows the thinking behind a language that would influence nearly every major language that followed.
The shape of the book
The three essays were written separately and circulated before the book was assembled. They differ in voice and method. Yet they share a direction of travel, and reading them in order is like watching one idea widen.
Dijkstra's notes come first and are the most personal. He writes in a reflective, almost conversational style, building his case from small observations about the limits of human reasoning. He moves from those observations to a set of principles for structuring control flow, and then to extended examples in which programs are designed step by step, with each decision examined. The examples are central. Dijkstra does not just state the method; he performs it on the page, showing his false starts and second thoughts.
Hoare's notes come second and are the most systematic. He turns from the actions a program performs to the data it acts on. He builds a classification of data types, starting from the simplest and combining them into more complex structures, and for each kind of type he discusses its abstract meaning, the operations that make sense on it, and the ways it can be represented in a computer's memory. The tone is that of a careful textbook, with the ambition of a manifesto: data deserves the same disciplined design as control.
Dahl and Hoare's essay comes last and is the most concrete about language. It takes the ideas of the first two essays, abstraction in control and abstraction in data, and shows how a single language construct, the class, can unite them. It explains how objects are created, how they refer to one another, how one class can extend another, and how objects can run as coroutines that take turns. It builds up to larger examples drawn from simulation, where the method shows its strength.
The movement of the whole book is from discipline of thought, to discipline of data, to a language that supports both. A reader who finishes it has seen the main ideas of modern program design in their first clear statement: stepwise refinement, restricted control structures, abstract data types, encapsulation, inheritance and layered architecture. Most later developments in programming methodology can be read as elaborations, corrections or rediscoveries of what these three essays laid out.
One should not expect the essays to agree on everything or to fit together seamlessly. They are three views, not one system. Part of the pleasure of the book is noticing where the authors' emphases differ: Dijkstra's suspicion of anything that cannot be reasoned about, Hoare's interest in the mathematics of types, Dahl's engineer's instinct for what a large program actually needs.
The limits of the human mind
Dijkstra's starting point is not the computer but the programmer. A human being can hold only a small number of things in mind at once. A program, by contrast, may involve millions of possible states and execution paths. The central problem of programming, as he sees it, is to bridge that gap: to arrange a large program so that a small mind can still be sure of it.
He draws an important consequence for testing. A test runs a program on a particular input and checks the result. If the result is wrong, the test has revealed a bug. If it is right, the test has shown only that the program works on that input. For any program of real size, the number of possible inputs is astronomically large, and no amount of testing can cover more than a tiny fraction. Testing can show that bugs are present; it can never show that they are absent. This is probably the most quoted idea in the book, and it is the foundation of the rest.
An analogy makes it concrete. Suppose a bridge is tested by driving a hundred cars across it. If one falls through, the bridge is unsafe. If none do, we know only that those hundred cars, at those times, crossed safely. No engineer would accept that as proof the bridge is sound. They would want a calculation showing that the structure can bear any load within its rating. Dijkstra asks programmers to aim for the equivalent: an argument, grounded in the structure of the program, that it behaves correctly for all inputs.
This is not a rejection of testing. Dijkstra knew that tests catch real errors. The claim is about what testing can and cannot establish, and about where confidence must ultimately come from. If correctness can be shown only by reasoning, then programs must be written so that reasoning about them is possible. That shifts the burden from the tester at the end to the designer at the start.
Dijkstra identifies three mental tools on which such reasoning relies. The first is enumeration: checking each of a small number of cases in turn. The second is mathematical induction: showing that something holds at the start and is preserved by each step, and therefore holds throughout. The third is abstraction: replacing a detailed mechanism by a summary of what it achieves, so that one can reason about its use without re-examining its insides. Every program construct, he argues, should be chosen so that one of these tools applies to it cleanly.
The idea is often confused with formal verification in the full mathematical sense, where every step is checked by a proof system. Dijkstra later pursued that direction, but in these notes his aim is more practical. He wants programs whose correctness argument a competent person could write out and check by hand. The reasoning may be informal, but it must be possible, and the program's structure must make it easy rather than heroic.
Where this leads is a change in the meaning of the word programming. If confidence must come from reasoning, then designing a program and designing its proof are the same activity. Dijkstra's later work, and the work of many who followed him, pursued that unity: deriving a program from its specification so that the proof grows alongside the code. Even programmers who never write a formal proof inherit the habit of asking, for each piece of code, what must be true here and why.
Control structures that match the reasoning
Given the three mental tools, Dijkstra asks which control structures a programmer should use. His answer is a small set. Sequence: do one thing, then the next. Selection: do this or that, depending on a condition. Repetition: keep doing something while a condition holds. Each of these has a simple correspondence with a mode of reasoning. A sequence is understood by understanding its parts in order. A selection is understood by enumerating its cases. A repetition is understood by induction, by finding a condition that holds before each pass and is preserved by the body.
The key property of these structures is that each has one entry and one exit. Control comes in at the top and leaves at the bottom. That means each structure can be treated as a single step at a higher level, which can itself be part of a sequence, selection or repetition. The program becomes a nest of boxes, each of which can be understood on its own and then used without looking inside. The text of the program and its behaviour line up: where you are in the text tells you where you are in the computation.
The unrestricted goto statement breaks this. A goto can transfer control from anywhere to anywhere. A program that uses it freely can arrive at a given line by many paths, each carrying different assumptions. To know what is true at that line, one must trace every path that leads there. In a large program this becomes impossible. Dijkstra's objection was not that goto is evil in itself but that it destroys the correspondence between the text and the process, and with it the ability to reason locally.
Consider a city with streets laid out as a grid of one-way blocks, where every intersection lets you continue straight or turn according to clear rules. Knowing your position tells you a lot about how you got there. Now imagine a city where any street may have a tunnel to any other street. Knowing your position tells you almost nothing about your route. Structured control flow is the grid. Free use of goto is the tunnels.
It is a common misunderstanding that structured programming simply means goto-free programming. Dijkstra's point was about structure, and the restricted constructs are a means to it. Later debate, notably Donald Knuth's careful 1974 paper on structured programming with goto statements, showed that there are cases, such as escaping from deep inside nested loops or handling errors, where a disciplined jump can actually make a program clearer. Modern languages provide limited forms of such jumps, such as break, return and exceptions, which preserve most of the reasoning benefits while allowing these cases. The spirit of Dijkstra's argument survives in them.
A related result, often cited in this context, is a theorem by Corrado Böhm and Giuseppe Jacopini from the mid-1960s showing that any program can in principle be rewritten using only sequence, selection and repetition. That theorem is sometimes presented as the justification for structured programming, but this misreads the argument. The theorem shows that the restricted structures are sufficient. Dijkstra's case is that they are good: that a program designed with them from the start will be easier to understand. A mechanical translation of tangled code into goto-free form need not be clearer at all.
Stepwise refinement
The constructive heart of Dijkstra's notes is a method of design, usually called stepwise refinement or top-down design. One begins with a statement of the whole task, phrased at a high level, as if one had a machine that could perform it directly. One then refines that statement into a small number of steps, each still abstract, connected by sequence, selection or repetition. Each of those steps is then refined in turn, until every step can be expressed directly in the programming language.
At each level, the designer reasons about correctness using only the abstract statements at that level. If the high-level steps are correct, and if each step is later refined correctly, the whole program is correct. Decisions about representation and detail are postponed until they must be made, and when they are made they affect only the part of the program being refined. The design becomes a series of small, checkable decisions rather than one large leap.
An everyday example shows the idea. Suppose the task is to prepare a meal for guests. At the top level: plan the menu, buy the ingredients, cook, serve. Each of these can be checked for sense before any detail is decided. Then plan the menu is refined: find out dietary needs, choose dishes, check that the timings fit. Cook is refined into the steps for each dish. At no point does the planner need to think about everything at once. And if one dish must change, only one branch of the plan changes.
Dijkstra demonstrates the method on worked examples of a kind familiar to programmers, among them producing a table of prime numbers and solving the classic puzzle of placing eight queens on a chessboard so that none attacks another. He shows the abstract program first, then the choices made in refining it, including choices he later reconsiders. A central part of the lesson is that refinement is not a straight line. One sometimes discovers at a lower level that a higher-level decision was poor and must go back. The method makes such backtracking manageable, because each decision is isolated.
Dijkstra extends the idea to families of programs. If a design is built in layers, then different programs may share the upper layers and differ only in lower ones, or share lower layers and differ in how they combine them. Seen this way, a program is one member of a family of related programs, and good design keeps open the possibility of producing other members cheaply. This anticipates much later thinking about software product lines, libraries and frameworks.
Stepwise refinement is sometimes misread as a strict rule to design everything from the top down and never otherwise. In practice, good designers combine top-down refinement with bottom-up construction of useful parts, and Dijkstra's own work on layered systems such as THE was largely bottom-up, each layer providing a cleaner machine for the layer above. The essential idea is not the direction but the layering: each level of the program should be understandable in terms of the abstractions offered by the level beneath it.
The method leads naturally to the other two essays in the book. If a program is designed in layers, each layer needs clean abstractions to work with. Some are actions, such as compute the next prime. Many are data, such as the set of squares not yet attacked. The question of how to define and represent such data abstractions is exactly the question Hoare takes up next.
Data deserves design too
Hoare's notes begin from an observation that seems obvious once stated. Most of the effort in early programming methodology went into the structure of algorithms, the order in which things are done. But programs are as much about data as about actions, and the choice of how to represent information is often the most important decision a programmer makes. Poorly chosen data structures make every algorithm that uses them awkward. Well-chosen ones can make algorithms almost trivial.
His approach is to separate two questions that programmers often run together. The first is abstract: what kind of thing a piece of data is, what values it can take, and what operations make sense on it. The second is concrete: how those values should be stored in memory, and how the operations should be carried out. Hoare argues that the first question should be answered first, in terms close to the problem, and the second only later, when the needs of the program are clear.
A simple example. A program needs to keep track of which days of the week a shop is open. Abstractly, this is a set: a collection of days, with operations such as add a day, remove a day, ask whether a day is included. Concretely, it might be stored as a list of day names, as a row of seven true-or-false flags, or as seven bits packed into a single number. All three representations serve the same abstraction. Which to choose depends on which operations are most frequent and how much memory matters. A program that thinks in terms of the abstract set can switch representations without rewriting its logic.
This separation, between what a type means and how it is implemented, is the core idea of abstract data types, which became one of the most important ideas in programming during the 1970s. Hoare's essay is one of its clearest early statements. It is closely related to his work on proving programs correct, because it lets one reason about a program in terms of abstract values and then separately prove that the representation correctly implements those values.
The idea is often confused with mere data hiding, the practice of making the internals of a structure inaccessible. Hiding is a useful enforcement mechanism, but Hoare's point is conceptual. Even in a language with no hiding at all, a programmer who thinks of data as abstract types with defined operations will write clearer programs. The abstraction lives first in the mind and in the documentation. The language may help or not.
A grammar of types
Having separated meaning from representation, Hoare builds up a systematic account of the kinds of data a program might use. The approach is compositional. A few simple kinds of type are taken as basic, and a few ways of combining types produce all the others. The result is something like a grammar: a small set of rules from which a great variety of structures can be built.
At the bottom are unstructured types, whose values have no internal parts. A type might simply list its possible values, such as the four suits of a deck of cards or the days of the week. Another might be a range of whole numbers. Such types seem trivial, but naming them explicitly, rather than encoding everything as integers, makes programs clearer and allows errors to be caught. A program that treats a suit as a suit cannot accidentally add it to a price.
Above these come the ways of combining types. One combination puts several values of possibly different types together into a single unit: a date made of a day, a month and a year, or an employee record made of a name, an age and a salary. Hoare discusses this as a Cartesian product, the mathematical name for the set of all such combinations, and in programming languages it became the record or structure. Another combination allows a value to be one of several alternatives, each with its own form, with a tag saying which: a shape that is either a circle with a radius or a rectangle with two sides. This is the discriminated union, which many modern languages offer as variant or sum types.
Further structures follow. A mapping from one type to another, such as from the days of the month to the rainfall on each day, corresponds to the array. A set of values drawn from some base type, such as the set of days the shop is open, is the powerset type. A sequence, a list of values of one type whose length may vary, covers files, strings and similar structures. And finally there are recursive types, defined partly in terms of themselves, such as a tree each of whose branches is itself a tree. Each of these is discussed abstractly, with its natural operations, and then concretely, with possible representations and their trade-offs.
The value of this classification lies in its generality. Once one sees that most data in most programs can be described with a few basic types and a few constructors, designing data becomes a matter of choosing and combining, not inventing from scratch. The classification also helps in reasoning. Each constructor comes with natural ways of proving things about the values it builds: by considering each component of a record, each alternative of a union, each element of a sequence, each branch of a recursive structure.
Hoare gives careful attention to representation. A set over a small base type can be stored as a row of bits, making membership tests and unions very fast. A set over a large base type cannot. A sequence can be stored in consecutive memory or as a chain of linked cells. A sparse mapping, where most values are zero or absent, should not be stored as a full array. For each choice he weighs the cost of operations, the use of memory and the difficulty of implementation. The discussion overlaps with the treatment of data structures in Knuth's first volume, which sits beside this book on the shelf, though Hoare's emphasis is on the link between abstract type and concrete form rather than on exact analysis of cost.
This grammar of types had a direct influence on programming languages. Niklaus Wirth's Pascal, designed around the same time, adopted much of it: enumerated types, subranges, records, variant records, sets and files. Later languages in the ML family made sum types and recursive types central. Many modern languages are still catching up with the full set of ideas in this essay. A reader who studies Hoare's classification will find it a useful lens for understanding the type system of any language.
Classes and objects
The third essay, by Dahl and Hoare, takes up a question that the first two leave open. If a program should be built in layers of abstraction, and if each abstraction may combine data with operations on that data, a language needs some feature that lets a programmer express such an abstraction directly. Their answer is the class, as realised in Simula 67.
The starting point is the block of ALGOL 60. In ALGOL, a block is a section of program with its own local variables. When control enters the block, the variables are created; when control leaves, they disappear. Dahl's insight was to imagine a block that does not disappear when its code finishes, a block whose local data persists and can be referred to from elsewhere. Such a persisting block, together with the procedures declared inside it, is an object. The description from which objects are made is a class.
An analogy helps. A class is like the design of a bank account form, specifying what information each account holds and what can be done with it: deposit, withdraw, show the balance. Each object is a particular filled-in form, belonging to one customer, with its own balance. The procedures belong to the class, but each acts on the data of the particular object it is applied to. Many accounts can exist at once, each with its own state, all sharing the same design.
This brings together the two streams of the book. The procedures of a class are the operations of an abstract data type. Its local variables are the representation. A program that uses the class can, if it is disciplined, work only through the procedures and never touch the representation directly, so that the representation can be changed without affecting the rest of the program. That is exactly Hoare's separation of meaning from implementation, now supported by a language construct.
Objects in Simula are referred to through references, values that point to an object rather than containing it. Several references may point to the same object, and objects may refer to one another, forming linked structures of any shape. This makes it possible to model systems of many interacting parts, such as customers, counters and queues in a simulated bank. Hoare's earlier work on record handling fed into this design, and the essay treats references with care, aware of the errors they can introduce.
It is a common confusion to think of objects mainly in terms of the features that later languages made prominent, such as message passing in Smalltalk or the elaborate class hierarchies of large frameworks. The original idea, as this essay presents it, is simpler and more fundamental: a unit of program text that defines a kind of data together with the operations on it, from which many independent instances can be created. Everything else is elaboration.
Hierarchy and extension
Simula 67 introduced another idea that has since become central: one class can be defined as an extension of another. The extended class, in Simula's terms prefixed by the first, inherits all its data and procedures and adds new ones of its own. Later this came to be called inheritance and the extended class a subclass.
The motivation was practical. In a simulation, many kinds of entity share common features. Every vehicle in a traffic simulation has a position and a speed; a bus also has passengers and a route; a lorry has a load. Rather than define each from scratch, one defines a general vehicle class and extends it for each special kind. Code that deals with vehicles in general works for buses and lorries as well, since they are vehicles. The hierarchy of classes reflects a hierarchy of concepts.
Simula also introduced virtual procedures, procedures declared in a general class whose actual behaviour can be supplied or replaced by each subclass. A general vehicle might have a procedure to compute fuel use, defined differently for each kind. Code that calls this procedure on any vehicle gets the behaviour appropriate to the actual kind. This is what later came to be called dynamic dispatch or polymorphism, and it is the mechanism that lets general code work with specialised parts it knows nothing about.
The title of the essay, Hierarchical Program Structures, refers to more than inheritance. Dahl and Hoare are interested in how a whole program can be organised as a hierarchy of levels, each providing concepts for the level above. A class can be used as a library of concepts for a particular kind of problem: a class for simulation, for instance, that provides processes, queues and a simulated clock. A program prefixed by that class has all these concepts available, as if the language had been extended for the problem at hand. This is the same layering Dijkstra advocates, now realised in language.
Inheritance is often misunderstood as primarily a way of reusing code. Reuse is a benefit, but the deeper purpose in this essay is conceptual: to let the structure of the program reflect the structure of the problem, with general concepts specialised step by step. Later experience showed that deep and tangled hierarchies cause their own problems, and modern advice often favours composition over inheritance. But the idea that a program can be built as a hierarchy of increasingly specialised concepts came from Simula, and this essay is its clearest exposition.
Coroutines and simulated time
Simula began as a language for discrete-event simulation, the modelling of systems in which things happen at particular moments: customers arriving at a bank, jobs entering a factory, vehicles reaching a junction. Such systems contain many active entities, each with its own course of action, interacting over time. The essay explains how Simula handles this, and the solution has broad significance.
Each active entity in a Simula program can be an object that has its own sequence of actions, which it carries out step by step. These objects run as coroutines. An object performs some actions, then hands control to another, which resumes from where it last stopped. Only one runs at a time, but each behaves as if it had a life of its own. Dahl and Hoare call this quasi-parallel execution: it has the logical structure of parallelism without the complications of truly simultaneous activity.
For simulation, a scheduling mechanism keeps a list of entities ordered by the simulated time at which each next needs to act. The entity at the front of the list runs until it must wait, for example until a service is finished, and then the next is resumed. Simulated time jumps from event to event. A whole day at a bank can be simulated in a moment, with each customer's experience recorded.
This combination of objects and coroutines was ahead of its time. It provided a model of concurrent activity that was safe and easy to reason about because only one entity ran at once. Later developments in concurrent programming, including Hoare's own Communicating Sequential Processes and the actor model, took the idea of independent agents with their own state further. Modern features such as generators and asynchronous functions are related descendants.
It would be easy to read this part of the essay as specialised material about simulation. It is better read as an early example of the general principle the book defends. A complicated system with many interacting parts becomes understandable when each part is described separately, with its own state and behaviour, and the interactions are managed by a simple, well-defined mechanism. The bank, the factory and the operating system are all such systems.
Layers of machines
Behind Dijkstra's notes lies an experience that the reader should keep in view: the building of the THE multiprogramming system at Eindhoven in the mid-1960s. That operating system was organised as a stack of layers. The lowest layer dealt with the processor and the clock, sharing the one real processor among several processes. The next managed memory. Higher layers handled the operator's console, input and output devices, and finally the user programs. Each layer used only the services of the layers beneath it and offered a cleaner, more convenient machine to the layers above.
The striking result, as Dijkstra reported it, was that the system could be tested and trusted layer by layer. Because each layer depended only on those below, it could be checked once those were known to work, and its correctness did not depend on anything above it. Errors could be located quickly, because each belonged to a definite level. The layered structure turned an impossible verification problem into a series of manageable ones.
This is the practical root of the idea of a program as a hierarchy of abstract machines. Each layer can be thought of as a machine with its own instructions: at the bottom the bare hardware, higher up a machine that offers processes and memory pages, higher still one that offers files and messages. A program at the top is written for the topmost machine and need not know how the lower ones work. Stepwise refinement, read from the other direction, is the design of such a hierarchy.
A modern reader meets this idea constantly without naming it. A network stack is layered in exactly this way, each protocol relying on the one below. A web application sits on a framework, which sits on a language runtime, which sits on an operating system, which sits on hardware. When the layering is clean, a problem can be diagnosed by asking at which level it lives. When layers leak, when an upper level must know about the details of a lower one, the benefits disappear and debugging becomes a hunt through the whole stack.
The idea is sometimes confused with mere modularity, the division of a program into separate files or components. Modules side by side are not layers. What makes a layered design powerful is the strict direction of dependence: each level rests on those below and is unknown to them. Dijkstra's insistence on this direction, and on the abstraction each layer provides, is what connects his work on operating systems to his notes on program design, and what links both to the hierarchical program structures of the Simula essay.
Correctness as the common thread
Although the three essays differ in subject, they share one underlying concern: how to know that a program is right. Dijkstra addresses it directly, through reasoning about control flow. Hoare addresses it through the separation of abstract types from their representation, which allows correctness to be argued at the abstract level and the representation checked separately. Dahl and Hoare address it through classes, which give that separation a boundary in the program text.
Around the same time, Hoare had published his axiomatic approach to programming, in which a program statement is described by what must be true before it runs and what will be true after. Such pairs of conditions, now known as preconditions and postconditions, make it possible to reason about each part of a program in isolation and to combine those pieces of reasoning into an argument about the whole. The essays in this book are less formal, but they assume the same picture. Each well-structured unit of program has a meaning that can be stated and checked.
An example clarifies the idea. A procedure that withdraws money from an account might require, before it runs, that the amount is positive and no more than the balance, and promise, after it runs, that the balance has fallen by exactly that amount. Anyone using the procedure needs to know only these two conditions, not how the withdrawal is carried out. Anyone implementing it needs to make only these two conditions true. The contract divides the work and the reasoning cleanly between them.
This way of thinking spread widely. Later languages built contracts into their syntax. Tools for static analysis and type checking enforce some conditions automatically. Even teams that never write a formal condition rely on the idea when they document what a function expects and what it guarantees. The book is one of the places where this practice first took clear shape.
The habit it teaches is still worth practising consciously. Before writing a piece of code, say what must be true when it starts and what it must make true when it ends. After writing it, check that every path through it keeps that promise. Most bugs are violations of a condition that nobody wrote down.
The tradition around it
Structured Programming answers the software crisis of the late 1960s, and it belongs to a group of works from that period that tried to put programming on a sound footing. Its immediate background includes the design of ALGOL 60, whose clean block structure and recursive procedures inspired all three authors; Dijkstra's 1968 letter on the goto statement; Hoare's 1969 paper on the axiomatic basis of programming; and Niklaus Wirth's 1971 paper on program development by stepwise refinement, which presented a closely related method with a clear example.
On this shelf, its nearest neighbour is Donald Knuth's The Art of Computer Programming, Volume 1, published four years earlier. Knuth's book and this one share a commitment to correctness and exactness but approach it differently. Knuth analyses particular algorithms in great mathematical detail, on a concrete machine. The authors here are more concerned with method: how to design programs of any kind so that their correctness can be grasped. Knuth's later paper on structured programming with goto statements was a direct and respectful engagement with Dijkstra's argument.
Frederick Brooks's The Mythical Man-Month, also on this shelf, looks at the same crisis from the side of project management. Brooks writes about teams, schedules and the organisation of large projects, drawing on his experience with IBM's OS/360. His concern with conceptual integrity, a system designed by one mind or a small group acting as one, is a cousin of Dijkstra's concern with a program whose structure mirrors a single coherent argument. Read together, the two books show that the crisis had both technical and human sides.
Later books on the shelf carry the ideas forward in different directions. Kernighan and Ritchie's The C Programming Language describes a language that adopted structured control flow fully, though it kept a goto for rare cases and offered only modest support for data abstraction. Abelson and Sussman's Structure and Interpretation of Computer Programs is in many ways the heir of this book's central theme. It treats programming as the construction of layers of abstraction, both procedural and data, and it teaches the separation of an abstract type from its representation as a basic skill. Readers who come to it after Hoare's notes will find the same ideas developed with great elegance.
Outside the shelf, the influence of the Simula essay is hard to overstate. Alan Kay's Smalltalk took the idea of objects and made it the whole of a language. Bjarne Stroustrup, who had used Simula, created C++ to bring classes to systems programming. Java, C#, Python and many others followed. Barbara Liskov's work on abstract data types and the language CLU developed Hoare's ideas about types and representation. The formal methods tradition grew from Dijkstra's and Hoare's work on correctness.
More distantly, the book connects with the theoretical books in this bay. The theory of computation, as in Hopcroft and Ullman or Sipser, studies what programs can do in principle. This book studies how humans can write programs they can trust. The two concerns meet in the theory of programming languages, where the meaning of each construct is given exactly so that reasoning about programs can be rigorous.
Questions and criticisms
The most persistent criticism concerns the gap between the ideal and practice. Dijkstra's vision of programs whose correctness is established by reasoning before they are run has been realised only in specialised fields, such as some safety-critical systems. Most software is still developed largely by writing code and testing it. Critics argue that full reasoning about large programs is too costly, that specifications are often unclear or changing, and that the method suits small, well-defined problems better than messy real ones.
Defenders reply that the ideas have succeeded in a diffused form. Structured control flow is universal. Abstract data types, interfaces and contracts are standard practice. Type systems, which check certain properties automatically, have grown steadily more powerful and catch errors that would once have needed reasoning by hand. Tools for formal verification have become practical for important components. The full ideal remains distant, but the direction it set has been followed.
A second criticism concerns the goto debate itself, which became more heated than the essay warrants. Some programmers took structured programming as a ban on all jumps and contorted their code to avoid them, adding flags and duplicated tests that made programs harder to read. Knuth's 1974 paper pointed this out with care. The lesson is that rules derived from a principle should not replace the principle. The aim is clarity of reasoning; any construct that serves it is acceptable.
A third point concerns object-oriented programming, which developed from the Simula essay in ways its authors may not have anticipated. Large class hierarchies became hard to understand and change. Inheritance was used where simpler composition would have served. Shared mutable state, objects changing each other's data through references, became a major source of errors, especially in concurrent programs. Later movements, including functional programming and newer type-oriented languages, have reacted against these excesses. Yet the original essay is more restrained than much of what followed, and a reader can find in it the core ideas without the later accretions.
Some details have aged. The examples are written in an ALGOL-like style unfamiliar to many readers today. Concerns about memory and efficiency reflect machines of the period. The discussion of references does not anticipate the full difficulty that would arise, which Hoare himself later admitted, calling his introduction of null references a costly mistake. The essays also say little about the social side of software development, teams, requirements and change, which later work showed to be as important as technical design.
What has held up is the fundamental argument. Programs must be understood by people. Understanding depends on structure. Structure in control, in data and in modules should be chosen to make reasoning easy. Every generation of programmers rediscovers this, often painfully, and this book remains one of its clearest statements.
A last criticism is about style. Dijkstra in particular wrote with a sharpness that some readers found arrogant, and his dismissals of other languages and practices could be harsh. This tone made enemies for ideas that deserved a calmer hearing. It is worth separating the manner from the substance. The arguments in his notes stand or fall on their own reasoning, and most of them stand.
Why it is on this shelf
This shelf gathers works that go to the root of their subject, for a reader who moves among Vedanta, Jyotish, science, economics and technology. In the craft of programming, this book is such a root. It does not teach a language or a tool. It teaches a way of thinking: that a complex artefact should be built so that a mind can grasp it, and that the limits of the mind should shape the method.
There is a resonance with the older traditions on the shelf. The Indian sastras, the systematic treatises on grammar, logic and ritual, were built with great attention to structure: short rules, clear definitions, careful ordering so that each part rests on what came before. Panini's grammar of Sanskrit is often cited by computer scientists as an early formal system of this kind. The discipline of making a large body of knowledge comprehensible through layered structure is old. This book applies it to a new material.
We also keep it because its three authors model different virtues. Dijkstra shows uncompromising clarity. Hoare shows the patience to classify and to connect theory with practice. Dahl shows how an engineer can turn abstract principles into a working tool that others can use. Reading them side by side is an education in how good ideas are made, tested and passed on.
And it is here because the problem it addresses has not gone away. Software today is larger and more pervasive than in 1972, and much of it is written quickly by people under pressure, and increasingly with the help of automated tools. The question of how anyone can be confident that a program is right has become more urgent, not less.
Finally, the book shows something about how a field matures. A craft becomes a discipline when its practitioners can state what makes work good, explain why, and teach it to others in a way that does not depend on personal genius. These three essays are an early and successful attempt to do that for programming. Any field, old or new, passes through such a moment, and it is useful to see one close up, in the words of the people who brought it about.
How to read it
Begin with Dijkstra's notes, and read the opening sections slowly. The reflections on the limits of the mind, the argument about testing and the discussion of the three mental tools are the philosophical basis of the whole book. They are short and dense, and they reward a second reading. Take notes on the argument as it moves.
Then follow Dijkstra's worked examples with a pencil. Do not just read the finished programs. At each stage of refinement, stop and try to make the next decision yourself before reading his. Compare your choice with his and ask what each assumes. This is the most valuable exercise in the book, and it can be repeated with any small problem afterwards.
On a first reading it is reasonable to skim Dijkstra's later and more specialised sections, returning to them once the main method is clear. The archaic notation may slow you down; translate it mentally into any structured language you know.
Next, read the Dahl and Hoare essay on Simula. It is the most concrete of the three and will feel familiar to anyone who has used an object-oriented language. Read it as history and as argument: notice what the original ideas were and how they differ from later practice. Work through the simulation examples with care, tracing which object is active at each moment.
Then read Hoare's notes on data structuring, but treat them as a reference to be studied in parts rather than read straight through. Begin with the introduction and the discussion of abstraction and representation. Then take one type constructor at a time, such as records or unions or sets, and for each think of an example from your own work and how you would represent it. The later sections on more complex and recursive structures can wait.
A good pace is one essay every two or three weeks, with time between them to try the ideas on real problems. The book is not long, but each part carries a lot of weight.
After this book, read Knuth's The Art of Computer Programming, Volume 1 for exact analysis of the data structures Hoare classifies; The Mythical Man-Month for the human side of the same crisis; and Structure and Interpretation of Computer Programs for the fullest later development of abstraction as the central method of programming. For a lighter companion to the debate on goto and clarity, Kernighan and Ritchie's The C Programming Language shows structured programming in everyday practice.
Throughout, keep one small program of your own beside the book: something you have written and know well. As each idea arrives, apply it to that program. Refine it again from the top; state the invariant of each loop; name its abstract types and their representations; ask which parts would make good classes. The book becomes far more useful when its ideas are tested on material you care about.
Questions to carry
- If testing cannot show the absence of bugs, where does your own confidence in a program actually come from?
- Which of Dijkstra's three mental tools, enumeration, induction or abstraction, do you rely on most when you read code?
- When is an early exit from a loop clearer than a structured alternative, and why?
- How would you refine a task you know well into three levels of abstraction, and where would you postpone decisions?
- For a piece of data in your current work, what is its abstract type and what is its representation?
- Which data in your programs would be better expressed as a discriminated union rather than as a record with optional fields?
- What is the difference between hiding a representation and abstracting from it?
- Where does inheritance clarify a design, and where does it hide dependencies that composition would make visible?
- What did Simula's coroutines make easy that true parallelism makes hard?
- What preconditions and postconditions are implicit in a function you wrote recently?
- Why might a mechanical removal of every goto make a program less clear?
- How does the idea of a program family change the way you would design a library?
- What would it take for a program written with the help of automated tools to be one that a person can still reason about?
Words to know
- Structured programming: designing programs with a few well-behaved control structures and layered abstractions so that their correctness can be reasoned about.
- Software crisis: the name given in the late 1960s to the widespread failure of large software projects to be delivered on time, on budget and working.
- Stepwise refinement: designing a program by starting with an abstract statement of the task and adding detail in small, checkable steps.
- Sequence: a control structure in which statements are executed one after another.
- Selection: a control structure that chooses between alternatives based on a condition, such as if-then-else.
- Repetition: a control structure that executes a body repeatedly while a condition holds, such as a while loop.
- Goto statement: an instruction that transfers control to any labelled point in a program.
- Invariant: a condition that holds before and after each execution of a loop body, used to reason about the loop.
- Abstraction: replacing the details of a mechanism by a statement of what it achieves, so it can be used without re-examining its insides.
- Abstract data type: a type defined by its values and operations, independently of how it is represented in memory.
- Representation: the concrete way an abstract value is stored and manipulated in a computer.
- Cartesian product: the combination of several values of possibly different types into one unit; in languages, a record or structure.
- Discriminated union: a type whose values are one of several alternatives, each tagged to say which; also called a variant or sum type.
- Powerset type: a type whose values are sets of elements drawn from a base type.
- Recursive type: a type defined partly in terms of itself, such as a tree whose branches are trees.
- Class: in Simula 67, a description of a kind of object, combining local data and the procedures that act on it.
- Object: an instance of a class, with its own copy of the class's data, which persists independently of the code that created it.
- Reference: a value that points to an object rather than containing it.
- Prefixing: Simula's mechanism by which one class extends another; now called inheritance or subclassing.
- Virtual procedure: a procedure whose behaviour can be redefined by subclasses, so that a call selects the version for the actual object.
- Coroutine: a routine that can suspend itself and later resume where it stopped, passing control to another as an equal.
- Quasi-parallel execution: Simula's model in which several objects each have their own course of action but only one runs at a time.
- Precondition and postcondition: what must be true before a piece of code runs, and what it guarantees will be true after.
A note on this edition
This is a study edition written for this shelf in our own words. It describes and discusses Structured Programming by O.-J. Dahl, E. W. Dijkstra and C. A. R. Hoare, but does not reproduce its text, programs or examples. The book itself is in copyright. It is worth finding in a library or from a bookshop and reading the three essays in full.