When did indenting appear in programs?

Program today and you would think that indenting has been around forever – but this is not the case. Don’t forget that until the mid 1960’s many programming languages were force-formatted, usually with 8 spaces before the left-justified code started, to hold any labels used in the program.

It wasn’t until the early to mid 1970s that people started to study the benefit of indentation and white space in making programs look “better”, i.e. easier to follow and modify. Some of these studies indicated that indentation inhibited program comprehension. Others, that programs with goto statements did not lend themselves to indentation, which isn’t surprising considering the unstructured nature of instructional jumps. In fact the 1970s was awash with studies on the effects of indentation, and commenting (another concept that seemed to be new).

Here is a Pascal program from Niklaus Wirth’s “Pascal: User Manual and Report” in 1975. Notice two things: indentation is 3 spaces, and multiple statements exist on single lines, for example on line 3 of the program. This is not untypical of the time, indenting was haphazard, and no attempt was made to give every statement its own line.

program exponentiation(input, output);
var e,y: integer; u,x,z: real;
begin read(x,y); write(x,y);
   z := 1; u := x; e := y;
   while e>0 do
      while not odd(e) do
         begin e := e div 2; u := sqr(u);
      e := e-1; z := u*z

So where did the use of 2 and 4 spaces come from? It is hard to trace the exact nature of the amount of whitespaces used. In 1983, Miara et al. [1] undertook a study to determine the impact of the level of indentation on program comprehension. Testing programs with 0, 2, 4, and 6 spaces on novice and expert programmers, their results gave favour to 2 or 4 spaces.

[1] Miara, R.J., Musselman, J.A., Navarro, J.A., Shneiderman, B., “Program indentation and comprehensibility”, 26(11), pp.861-868 (1983)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.