MAN VS. THE COMPILER

Another of my rants on languages and how they are taught in college; this time the topic is Fortran.

When last we met, I was wafting ill about Pascal. That was BEFORE I took FORTRAN. I’ve heard that FORTRAN was an obsolete language, too elderly to be of any use today, but people have been saying the same about BASIC for as long as I can remember, so I took the plunge. What follows are my reflections on FORTRAN, methods of teaching computer languages, the ACTUAL advantages of learning Pascal as a requirement so one can learn “structured” programming techniques and, finally, my philosophy as to the “ideal” computer language.

Before I proceed further, I should set the background of the course: we were using F77, the latest enhancement of the language which first premiered in 1957. This has several advantages over previous versions, especially the unformatted TYPE *, statement. Before this, all writing to the screen or printer required two statements:

WRITE(5, 100)

100 FORMAT( 34H, THIS WILL BE TYPED ON THE PRINTER)

The WRITE statement set the machine up to look for a statement, 100, which would tell it what and how to print. The 5 tells it where, as each I/O device has a different “call number,” 5 being the CRT. READ statements are like the WRITE in FORTRAN in format and are like the INPUT in BASIC. One big pain in the very early versions of FORTRAN was the “34H” you see in the FORMAT statement. What you previously had to do was count what you wanted printed, add 1 space to start the line and put that before the statement to be printed. F77 lets you replace it with:

100 FORMAT(‘ THIS WILL BE TYPED ON THE PRINTER)

A considerable improvement. The TYPE statement is even easier:

TYPE *, ‘THIS WILL BE TYPED ON THE PRINTER’

I get the feeling this is frowned on in the FORTRAN world and is to be used only in the debugging of a program so you can force it to output values to see why your creation is blowing up in your face.

On first glance, FORTRAN is superficially much like Pascal. But on more complete perusal you see major differences – line numbers but only for reference not as in BASIC, and they don’t have to be in any kind of sequence. Again, like Pascal, there are subprograms, called SUBROUTINEs and like Pascal are CALLed with the passing of variables and the possibility of local variables – used only in that part of the program and having no affect on any others any others. However, unlike Pascal, you don’t have to declare any variables as anything unless you want to change the default of all to be REALs except I through N. There has been a change in FORTRAN, as in the rest of computer science in the last few years as memory capabilities of the machines have grown (here I mean main frames) and the need for a sparse, scimpy code to save the meager memory of the machines is no longer necessary. So, they have “spread” out their code to make it more readable, i.e. understandable to someone besides the creator, and as part of this a generally top – down approach, so much favored by the Pascal people, the old habit of using flocks of GO TOs is being shucked as a disreputable hang over from the distant and dismal past. The philosophy behind this is the extra expense of the additional memory will be more than saved in the time required to debug or modify already written code as bugs appear or requirements change. Today, as we all see, the price of memory is minuscule fraction of early days but the cost of programmers time has popped through the roof. Therefore, buy memory and save money is the operative philosophy.

The teacher we had knows his FORTRAN but I feel made some serious mistakes in getting this language across to us. I would guess he wanted to show us how the new F77 enhancements made the language more powerful. Fine. But he spent time teaching the OLD method, gave us an assignment using the OLD method, THEN told us the new. Why? Why did we have to waste our time learning a technique no one in his right mind would ever use? It was tantamount to teaching everyone to use steel and flint, then teaching them how to use a BIC. True, they’ll appreciate the BIC even more – but what will they think of the guy who forced them, unnecessarily to freeze until they got the embers to catch? In case you missed my point: NEVER teach a student the old way first – especially in a fast paced summer course which allows only one month to learn an entire language. You can mention the old way in class, just to show how far we’ve come, but why make the kiddies do it that way?

Some suggestions on how to bring new concepts forward, or rather NOT to be done. When we got a new concept, such as searches, sorts and loops, instead of trying out one of them in an assignment we were hit with all three. When the program kept bombing, we were so overwhelmed we were unable to tell whether the problem was logic or syntax and if logic, where the error was since so much was going on. The net result was I left the house at 9AM for a 10 – 12 class and during the last two and a half weeks often didn’t return home until 8 or 10 at night. Lest you think that I was the only fool – most of the class was right beside me going nuts at about the same rate. Had we been given more, but smaller, assignments, then assembled them after we knew that each worked and HOW they worked, we would have been given a more realistic programming situation and would have limited our gut wrenching panic at the keyboards.

Now that I’ve vented my spleen about the course, let me heap, once again, displeasure on the pretensions of Pascal. I must admit I was helped in tackling the assignments by what I learned in the earlier Pascal course – especially pseudocode. Pseudocode is a way of saying what you have to do in little pieces, then step by step making the English code into more and more computer like code. And it helped that I’d learned the top down method of programming. The only problem is that you could have learned these two concepts anywhere, from any language including BASIC, with much less aggravation. As I said in my last article – these concepts can be learned in BASIC and it is mere pretentiousness which has Pascal people looking down on BASIC as a TEACHING tool. At Beaver, BASIC is being taught this way with much less trauma because of its interactive quality – especially during debugging. We were using FORTRAN on a PDP-11/70 and we had to do the following:

  • Write the program in an editor creating a file such as ONE.FTN, the FTN being the extension the compiler would look for. The editor was nothing special, as far as FORTRAN was concerned and was used by others just writing letters.
  • Call the compiler using this command: F77 ONE,ONE=ONE. This called the FORTRAN 77 compiler as well as created several files including a backup file and a listing file to be used to store the errors which it found in your code.
  • Any errors are listed by line number. But of course, your code has no line numbers. And lest you be confused even further, the line numbers YOU put in as reference lines are NOT what I’m taking about.
  • To see the errors you have two choices:
    1. Print out the ONE.LST file. This file has all your errors. The error code will be just after the line which caused it to flag it. It will list all errors, and you must be careful since one error can cause a cascading effect, creating many others.
    2. List it to the screen via the editor or just run it by your eyes. This is usually not very satisfactory as you still have to write down the error line, the correction and then do it. I usually used the first method.
  • When you have corrected all your errors, you have to TASKBUILD, where the various library functions are tied to your program. The code for this is TKB ONE=ONE. This was an interminable step which gave you time to comtemplate your navel or, alternately, wonder what the G-ds had in store for you, next.
  • FINALLY, to run your program you type RUN ONE and then worry about your logic. And just because your program wasn’t flagged for certain errors before, doesn’t mean all is well; if you have a conflict with variable type (REAL, INTEGER, LOGICAL or CHARACTER) it will bomb on you THEN. So it’s back to the editor, compiler and taskbuilder all over again.

As I stated earlier, since so much was going on in these programs for us beginners, we were going into these steps over and over again – often blindly. Admittedly, this is bad, stupid and a waste of time but this was the way we were all doing it – I see this NOW. Yet we got no guidance from the teacher on how to avoid this. I feel when a teacher is aware of considerable flaw in the way his class is attacking its assignments, it is the teacher’s obligation to try to set them straight – not to let them flounder. It was an awful experience – and one which could have been made less so if the teacher had shown that understanding.

Very well, enough of my spleen venting. What comes next is the Stoloff solution to all programming problems. The language which should be adopted as the OFFICIAL language for all uses is (guess!) BASIC! Why this retrograde conclusion? The new GW (Gee Wiz) BASIC has practically all the bells and whistles of these other languages with the advantage of INTERACTIVE debugging. The old ATARI 800 had a BASIC which told you of each error as you entered it. That’s interaction! But what about the speed of Pascal vs. BASIC, you say? Poppycock say I. Speed is only a benefit when the program is RUNNING! All the speed in the world is of no use when it keeps blowing up on your screen. My suggestion is to us a compiled BASIC. You compile it ONLY when you’ve got it so it runs and runs correctly. The time saved in debugging would be enormous. But what about the ability of Pascal to append libraries of neat little procedures into the program you’re writing? Simple, just number them beyond a range usually used in normal BASIC programming or, at worst, renumber them before merging. This little inconvenience is one I would gladly exchange for all the waits of the “superfast” compiled languages.

Leave a comment