Friday, July 28, 2017

Learning Fortran is a waste of your time

Suppose you are an advanced student of physics, and you're just beginning your first research experience with a new professor.  You're excited about the opportunities this means for your future, fascinated by the implications of the research, and anxious to please.  Your professor tells you you need to run a computer simulation, and this is also exciting; you've never used a computer as a computer before -- usually just as an internet browser.  To get you started, he points you to a reference text with some sample code, or sends you one he has on his hard drive somewhere.

This code will be written in Fortran.  They all are.  All legacy codes are Fortran.

So what is Fortran?  Fortran is a high-level programming language designed back in the 50's.  Here "high-level" means that it is not assembly language, and the programmer does not directly interact with machine elements like bits, bytes, or memory addresses, though Fortran is much "lower-level" than most modern languages like Java or Python, meaning it is only just a step or two above machine code.  The name "Fortran" is short for "Formula Translation," as the language was intended to more directly translate a mathematical formula into computer code; Fortran allowed, for instance, an entire mathematical expression to be written out as a single line of code, as opposed to assembly, which would require multiple lines of register swapping and simple operations to acheive the same result.

You'll get the sample code and look at it, and it will be completely incomprehensible.  They all are.  All Fortran codes are incomprehensible.

Why is this?  There are a lot of things that contribute to the issue.