Tuesday, September 26, 2006

.

APL vs FORTRAN

Let's go back in time again to the U of FL computer systems in the mid-1970s. This is a story about my time as a consultant, and my delight with APL. (Actually, the latter comes from way back — I was unusual in that my first programming language was APL. My first exposure to computers was in eighth grade, when my school brought in an APL terminal, which we would dial into one of the colleges in south Florida, using an acoustic coupler. The first program I ever wrote, my version of "Hello world!", was an APL program to solve quadratic equations.[1])

The aforementioned Mike (from my prior reminiscence) and I were hanging out in the consultants' room after hours, but not long after hours. A man walked in, with a stack of program listings and a puzzled expression. "Can you help me," he asked, "with a problem with a FORTRAN program?" We said we would try. We soon learned that this wasn't a problem with a course assignment, but trouble with a program they'd gotten from outside the university. A research project they were working on generated data in a few matrices, and there was a particular matrix operation they needed performed. The program supposedly performed it. The trouble was that they had a set of known data with a known result, and when they put their sample data into the program they didn't get the expected result.

The guy showed us the matrix formula, something that used some standard matrix multiplication, inner product, and such — a normal sort of thing but very cumbersome to do by hand on large matrices. And difficult to program in FORTRAN... the program was several pages long and was giving the wrong result. We looked at it for a while, and, not surprisingly, nothing jumped out at us.

After a bit of this, I asked if it were possible that their "expected" result might be wrong. He doubted it, but said that it was possible. Since the operation was straightforward, and since APL is perfect for matrix manipulations, I took the formula and coded it in APL. It took 12 characters of APL. Not 12 pages. Not 12 lines. 12 characters. It took longer to type in his test data than it did to write the APL program. We put in his test data. We got the expected result. OK, they were correct, and the FORTRAN program was wrong. We looked some more.

After another bit of this, I said, "Wait... Do you need the FORTRAN program to work? Or do you just need a program that does this matrix operation?" He said he just needed a program. We gave him the APL program and sent him on his way.

12 characters of APL. And then it was Miller Time.[2]


[1] OK, now you understand how I got this way.

[2] I don't know about Mike — I haven't seen him in 29 years — but I, at least, drink better beer now.

No comments: