I am interested in finding out who introduced code indentation, as well as when and where it was introduced.
It seems so critical to code comprehension, but it was not universal. Most Fortran and Basic code was (is?) unindented, and the same goes for Cobol.
I am pretty sure I have even seen old Lisp code written as continuous, line-wrapped text. You had to count brackets in your head just to parse it, never mind understanding it.
So where did such a huge improvement come from? I have never seen any mention of its origin.
Apart from original examples of its use, I am also looking for original discussions of indentation.
5
The origins of indented code probably can be found in ALGOL:
ALGOL introduced code blocks and the
begin
andend
pairs for delimiting them and it was also the first language implementing nested function definitions with lexical scope.
4
Indented code must have arrived prior to 1958, since it was present – but not ubiquitous – in LISP and ALGOL. The earliest I can locate is COMTRAN which was introduced in 1957, although I can only find the 1960 manual only (see page 90ish). This indentation differs from the modern conception since COMTRAN lacks the block structure of most languages since ALGOL but I think it should still count.
I suspect that this is not actually the first example but I cannot locate any earlier.
Updated
It has occurred to me that to a meaningful degree indentation probably predates programming. Indentation was likely used in instruction lists prior to anyone writing computer programs. Unfortunately I can’t find any good examples of this.
An expansion on Ross Patterson’s comment – COBOL compilers (or at least IBM’s compilers, which I used in my pre-open systems career) enforced indentation (the “A” and “B” areas he mentions). If any of the elements that were required to be in these areas were not placed exactly, your code would fail compilation. However, beyond that no specific indentation was required – this often led to griping when modifying the code of another developer whose indentation style was different than yours – etiquette would suggest you follow the existing pattern as that preserved peace among peers; additionally, different styles in the same source would be aggravating to view, almost Tetris-like in appearance.
It’s been years since I’ve thought about COBOL and its indentation – thanks for asking the question and providing a little trip to the past!
Marty