One of my more favored software development blogs is Beautiful Code. The concept is that code that is properly elegant is going to be readable, functional, and most of all, working correctly. There’s a lot of focusing on unit testing, proper OO design techniques, and how to squeeze an elegant solution out of the nastiest conditions.
Well, I believe I have a Nasty Condition.
I hack on FORTRAN and Fortran at work, after getting out of the IT support gig. What’s the difference between the capitalizations? Easy. FORTRAN references the language pre-1990 (1950’s through to 1990), and Fortran is the more modern Fortran 90/95/2003 standards.
Fortran 90/95/2003 isn’t that bad to work on, actually. For its primary purpose (running numerical computations on hideously expensive computers), it works really well, and makes me a happy hacker.
FORTRAN helps to create ugly code. Complex looping and branching statements are much more difficult than in other languages, and many FORTRAN coders cut their teeth on it when the language was still implemented via punchcards, and “eloquent” coding meant as few cards (aka lines of code) as possible. Goto statements scare me. Gotos with literally 5-6 arguments terrify me. Did I mention that there’s limitations on line length imposed upon the language from punchcards?
The code in specific I’m working on is worse. Those working on it use no version control, so it’s full of commented-out things every which way, and it definitely dates from the punchcard era, as it lacks things like blank lines in between logical blocks of code statements. It has terrible, nonsensical indenting, and it relies heavily on subroutines acting in highly non-documented ways on literally hundreds of different, poorly named and undocumented, global variables.
Oh, and there’s a function that simply wraps ACOS(), the cosine function in FORTRAN. This is what it does:
FUNCTION ARCOS(X)
ARCOS = ACOS(X)
RETURN
END
Lovely, yes? Waste of a function to have to keep track of, yes? I’ve seen it in three different versions of the model, and it troubles me the same.
I also saw references to MS-FORTRAN 4.0 for MS-DOS in the comments. Joy of Joys. In addition, it will only compile with Intel Fortran. Portland Group’s compilers break a little bit on it, but gfortran, g95, g77, f2c, and sunf77 compilers all fail with pretty pyrotechnic displays with it.
Hopefully this stuff won’t drive me completely batty before I can understand what it does “under the hood” enough to re-write what I need out of it in something better.