Rethinking Structured Programming

The evolution of programming

Randal Kamradt Sr
Level Up Coding
Published in
4 min readDec 31, 2020

--

The Thinker by Rodin
Image by Johnnie Shannon from Pixabay

In my recent article, All Loops are a Code Smell, I asserted that the normal forms of looping, for, while, etc, are a low-level coding construct to be avoided. While the overall response to this article was good, there were some very noisy objections by people that obviously weren’t buying it. So I thought I would spend some more time going over my reasoning.

Let me start with the idea of Structured Programming. The early thoughts on Structured Programming were started in the late 1950s. Edsger W. Dijkstra wrote an open letter in 1968 “Go To Statement Considered Harmful” in which he implored programmers to abandon goto statements in favor of more controlled application routing such as if and while statements and separate subroutines. Donald Knuth wrote a rebuttal in 1974 “Structured Programming with go to Statements.” But it was mainly about optimizing every CPU cycle and maintaining ‘Provability’, and high-level programmers should be delaying optimization until shown to be needed. The goto statement of course still exists today as a coding escape hatch but is generally considered a code smell.

When I first started coding professionally way back in 1989 (I remember because it was the year my son was born) there were still people that thought goto was an appropriate form of coding. P. J. Plauger, an early adopter of structured programming, said this:

Us converts waved this interesting bit of news under the noses of the unreconstructed assembly-language programmers who kept trotting forth twisty bits of logic and saying, ‘I betcha can’t structure this.’ Neither the proof by Böhm and Jacopini nor our repeated successes at writing structured code brought them around one day sooner than they were ready to convince themselves.

So I’ve been thinking about the concepts of Structured Programming, and what parts might now be considered low-level abstractions that can be buried away in some library. The goto statement never went away, it is still used at the machine code level. But most of us don’t program at that level. Perhaps high-order functions can make some of the constructs of Structured Programming as unnecessary as the goto statement, only to be used on the rarest of occasions.

--

--