Happy Birthday, FORTRAN

I first got started in working with computers and software back in 1970, when I was an undergraduate student in physical chemistry.  At the time, slide rules were still the computing technology of choice for everyday student use, yet some of the problems we worked on required much more precision than a slide rule could deliver.  Early electronic calculators were available, but were very expensive, at least for a student on a budget.  The chemistry department had a very nice electronic model (costing, I think, several thousand dollars), which even had built-in functions (e.g., sin, cos, log); but it lived in its own little room in the lab.  I had a key to the door, but the only time lowly undergraduates could get a look in was in the wee hours of the night. The idea of using one of the electro-mechanical calculators (called “watchmakers’ nightmares”) was not appealing, so I signed up for an evening course in FORTRAN programming.

So I was amused today to see a story at Wired magazine commemorating the introduction, by IBM on this date in 1956, of the first programming manual for FORTRAN [PDF].  Prior to the introduction of FORTRAN, programs were written in what today we would call assembly language.  This probably seemed entirely natural at the time; stored-program computers were a novelty, there were not many of them, and most of those that existed were to some extent “one-off”, customized machines.  The idea that one program could be written that would run on multiple machines was more a fantasy than anything.

A young programmer at IBM, John Backus, who had studied mathematics at Columbia, thought there should be a better approach:

In 1953, frustrated by his experience of “hand-to-hand combat with the machine,” Mr. Backus was eager to somehow simplify programming. He wrote a brief note to his superior, asking to be allowed to head a research project with that goal. “I figured there had to be a better way,” he said.

Although the actual programming environment was not released until the following year, the ideas that Backus’s group developed had great appeal:

The new invention caught quickly, no wonder; programs computing nuclear power reactor parameters took now hours instead of weeks to write, and required much less programming skill. Another great advantage of the new invention was that programs now became portable.

The whole idea of portable programs was able to be explored and developed for the first time.

That first FORTRAN manual opened with this example pseudo-program, to give readers a flavor of the new language:

      BIGA = A(1)
      DO 20 I= 2, N
      IF ( BIGA - A(I) ) 10,20,20
10    BIGA = A(I)

(I have added the column markings in italics at the top.  FORTRAN was originally defined with 80-column punched cards as the source code input medium.  A ‘C’ character in the first column meant the line was a comment.  Columns 1-5 were reserved for statement numbers, and a non-zero character in column 6 indicated that this card was a continuation from the previous card.  Ordinary program statements began in column 7.)

Experienced FORTRAN programmers will note that this is not a complete program.  For one thing, there is no mechanism for getting values into any of the variables, and a DIMENSION statement would be required to define the array ‘A’.   The STOP and END statements are also missing.  The conditional statement, of the form:

    IF ( expression ) a, b, c

requires a bit of explanation: the expression is evaluated, then the program branches to statement numbers a, b, or c, depending on whether the value is less than, equal to, or greater than zero.

That early language had some other odd quirks.  For example, there was a form of the IF statement:

    IF ( SENSE LIGHT i ) a, b

which branched to statement number a or b depending on whether Sense Light i (i=1,2,3, or 4) was ON or OFF.  (The Sense Lights were indicator lights on the console of the IBM 704.)  Also, although in keeping with FORTRAN “tradition”, variable names beginning with the letters I-N were automatically typed fixed point (integer), and the rest (beginning with A-H, O-Z) were floating point, functions that returned integer values had names starting with ‘X’.    (A foolish consistency has never been much of a hobgoblin in the software world.)

By the time I got started with FORTRAN, in 1970, it had progressed from FORTRAN I, as described in that first programmer’s manual, to FORTRAN IV, which in turn served as the basis for the development, by the American Standards Association (now ANSI), of the first standard for a high-level language, FORTRAN-66 in 1966.   The language still had its quirks.  One was that blanks in the source code were completely disregarded, which is tied to two of my favorite FORTRAN IV trivia questions:

  1. What kind of statement is this, and what does it do:
    DO 200 J = 1 50
  2. What is the only reserved character sequence in FORTRAN source code?

(The answers are below.)

At about this time, as I was dutifully punching cards with my FORTRAN programs to be run on the IBM mainframe under OS/360, UNIX and the C language were just getting off the ground at Bell Labs.  Although people today often think of FORTRAN as being very old-fashioned compared to C, the languages are actually at similar levels in terms of their distance from the “bare metal”.  FORTRAN of course was designed with scientific and engineering computation in mind, and lacks C’s character manipulation and system interface features.  Still, it was quite common in those early days to hear C described as “FORTRAN with pointers”.

A little later on, the “structured programming” movement got underway, sparked in part by the publication of Edsger Dijkstra’s famous letter, “GOTO Statement Considered Harmful”, in the Communications of the ACM.  This in turn motivated a later parody, “Real Programmers Don’t Use Pascal”, which appeared in Datamation magazine.  (The title is a play on a best-selling book of the time, Real Men Don’t Eat Quiche.)

This has all been great fun to watch as it evolved, while I was in the process of writing many thousands of lines of FORTRAN code, for lots of different types of applications, including:

  • Investment risk analysis
  • Portfolio selection
  • Monte Carlo simulation
  • Option valuation
  • Statistical analysis
  • Portfolio accounting
  • Investment performance measurement

and lots of other things.  (I did manage to pick up some other languages along the way, like PL/1, C, and Java.)  FORTRAN was a tool that was initially not too intimidating for someone from a scientific background, like me; and it was, like C, close enough to the machine that it could be used to tackle a lot of problems beyond its originally envisioned scope.

There’s a user-written “practical guide” to FORTRAN available at the ibiblio site.

Oh, and I almost forgot — the answers:

  1. The statement is an assignment statement that sets the value of the variable DO200J to 150.  It would require a comma between the ‘1’ and the ’50’ to be a DO (iteration) statement.
  2. The only reserved character sequence in FORTRAN IV is ‘FORMAT(‘.

Comments are closed.

%d bloggers like this: