Monday, June 1, 2015

I’ll Give up Fortran when they Pry it from my Cold, Dead Hands

Yes, I still program in Fortran.  And I’m proud of it.  Every so often I tell my colleagues that it’s finally time for me to pick up a new programming language.  Maybe C++.  Or Java.  Lately, Python.  But then I sit down in a quiet place and the urge passes.  You just can’t beat Fortran, and here’s why:

  1. The goto statement. Nothing says “I’m the boss, and you’re the servant” to the computer quite like the goto statement.  Go HERE and do THIS. Yes, I know that it’s fallen out of favor now that computer scientists have taken over computers and ruined all the fun with “structured programming” and similar barbarities. A well-structured program marches forward like a crisply-organized military parade. But I think a program should be more like a boat ride down a meandering river – you just never know where you’re going to end up.
  2. Fortran puts you in contact with the history of computers. With the older Fortran compilers, any part of your Fortran code that exceeded 72 characters on a line would be ignored. Why? Because that’s  the number of spaces on a punch card!  (No, I have never used punch cards.  I’m not that old). And nothing beats the fun of putting your nose up on the screen while you count the characters in every line. But it's easier just to get more and more cautious about exceeding the 72 character
  3. limit until your program
  4. starts to look like
  5. this.
    Does the phrase "Do not fold, spindle, or mutilate" mean anything to you?
  6. Nothing is quite as confusing as a poorly documented Fortran program. Yes, I know that any program can be confusing if it’s badly documented, but Fortran excels in this regard. Once you’ve inserted lots of goto statements, so that your program looks like a bowl of spaghetti, and you’ve neglected to write any comment statements (I’m in a hurry), and the program is just one big block without any subroutines (I already said I’m in a hurry), the final product will be nearly incomprehensible. Hey, it’s my program. Why would anyone else need to understand it? Besides, if my program should fall into the hands of terrorists, I wouldn’t want them to use it to understand the nature of the dark energy in the universe. I once wrote a program that grew so complex that I no longer fully understood what it was doing. That’s why we call it “research.”
  7. Fortran won’t “nanny” you. My Toyota won’t even let me open the door unless the transmission is shifted into park, and it’s constantly whining at me if a door is left ajar, or somebody forgot to wear seat belts. Fortran lets you open up all of its doors and cruise down the highway at 80 miles an hour without seat belts. Exceeding the dimensions of an array? No problem!  Fortran will just overwrite some other area of the memory –you probably weren’t using it for anything important anyway.  No need to declare variable types at the beginning of the program (like I said, I’m in a hurry) – just remember that variables beginning with “i” through “n” are integers, and everything else is a real number (or is it “j” through “p”?) And should you accidently use the wrong variable type, Fortran will happily round off all of your real numbers to integers without even telling you.  That’s service with a smile!
  8. Infinite loops! Is the program taking too long to run, or have I inadvertently created an infinite loop? A great excuse to stop for lunch and check back a few hours later! Goto 1.


Anonymous said...

Maybe you should try to learn FORTRAN 2003.
Try to stay away from F77 as far as you can.
It is 2015 now. But most people still use or think in FORTRAN 77.
So, FORTRAN is dying.
This language is designed for scientific users and it is killed by scientific users.

Hamish Johnston said...

When I was at high school we learned how to program using Fortran on cards. The teacher would take the card deck up to school-board HQ every day after school and we would get our print-outs the next day (often with errors!). It's difficult to comprehend in this age of instant gratification, but it did did teach us to be very careful with the stucture and syntax of our programs.

Hamish Johnston said...

Ha ha, that should be "structure". I wouldn't have made that mistake on a card!

Robert Scherrer said...

The funny thing is that everyone I know who programmed on punch cards is vaguely nostalgic about it.... and now their programs always run perfectly the first time!

Hamish Johnston said...

I'm afraid the bad habits set in when our computer science class went on a field trip to the University of Waterloo, where we could actually sit at a mainframe terminal and program Fortran in real time!

bill e.g. said...

Oh that is hilarious. I guess that was a "defense" of still coding in Fortran.

Yes I learned Fortran, then C, then C++, then "Object Oriented-style" C, then I got mad at C++ (anyone else? circa 1999 with their big re-write of the language and libraries), then Perl for some simple and web stuff (remember I was mad at C++), then Python for some simple and web stuff (I got mad at Perl and the darn 12 styles/formats for your program attitude)...

If this sounds like "thrashing" about then you are probably right. Nowadays I like Python, C++, Mathematica, and LabVIEW. They are all similar enough and different enough that I have to really focus on which language I am in. Kind of like driving on the left side of the road if you are used to the right side.