Did old code have weird style?

Look at many pieces of code in old programming books  (we’re talking pre 1975), and you might notice one thing… the code had an odd style to it. Consider the following piece of Algol 60 code:

gcdalgol

Note that likely the biggest style change here is the use of singular lines of code to hold entire structures. This is most noticeable in things like the if statement, where begin-end exist in linear form. As I mentioned in a previous post, indenting was rudimentary, with 3 spaces being used, and no real attempt to stretch out control structures. The code also looks odder because the code is shown in a proportional font, as opposed to Courier.

Does this code look aesthetically pleasing? Is there an inherent problem with linear structures such as this? Maybe not. Maybe we need to rethink how we style code for certain structures? Consider the code above translated to C (yes, and leaving in the goto statements).

gcd_c1

You know what? It’s not terrible. The if statements would each take up 4 lines of code, where they coded to most normal standards, i.e.:

rep1: if (m >= n) {
          m = m - n;
          goto rep1;
      }

Maybe this just isn’t necessary for small control structures? Food for thought.

 

 

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