How many goto’s in old code?

In 1971, Donald Knuth published a paper, “Empirical study of FORTRAN programs”, in Software Practice and Experience. In it he studied over 250,000 lines of Fortran code from Lockheed and 11,000 lines from Stanford University. Knuth determined that the four most popular statement types account for over 70% of the lines of code. What were they?

knuthfortran

So GOTO accounted for 13% of statements in the Lockheed code, or 24,942 times. Of the 28,783 IF statements found in both studies, 8,858 statements were arithmetic IFs, while the remaining 19,925 had the form of IF(…), and 71% of those were IF (…) GO TO. So statements involving jumps of some form abounded! Now imagine re-engineering one of these *behemoth* legacy programs with *that* many goto’s.

Knuth, D.E., “Empirical study of FORTRAN programs”, Software-Practice and Experience, 1, pp.105-133 (1971).

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s