So in order to further educate myself on the matter of programming languages, I’ve decided to once-in-a-while try out a language, take it for a test drive, and try to make something useful. I will not be teaching you the language, and I will not specify all the details, but I will try to inform you of the major strengths and weaknesses of the language. So the first language I’ve decided to try is the oldest language still in use: Fortran.
Maybe it’s just me, but Fortran is one of the coolest sounding things ever. It sounds futuristic, powerful, like the name of some kind of galactic empire.

John Backus, designer of Fortran
So, a quick trip to Wikipedia told me that Fortran is a general purpose, procedural, imperative programming language. I like the sound of procedural and imperative, two programming paradigms that seem to fit well with my brain. I scrolled down to look at some example code. The syntax looked exotic, but I was able to understand it thanks to comments and my own intellect. Now I was ready to learn the language.
First I had to find a tutorial, and like many programming languages, there’s many implementations and standards of Fortran. I’d decided to go with Fortran 90 because I couldn’t really find anything entry-level for later versions, and Fortran 77 appeared to be in a deprecated state (i.e. no new code is written with it).
Now it could very well be that my perception of a language is based entirely on the writings of the tutorial, but I tried to focus on code and not on my ability to understand the writer.
My very first Fortran program was the old Hello World program:
program Hello
print *, 'Hello, world!'
end program Hello
Pretty straight foward. Again, the imperative paradigm I’m used to. So as I followed further examples, I discovered that Fortran has a pretty clean syntax, not what I expected, especially for an old language. There’s obvious bullshit initialization code at the top and bottom of every program, known as the program statement, but you’d probably have that on your programs anyways, even if it wasn’t required, in the form of a comment (I know the GNU people love putting copyright notices everywhere). Now let’s look at a small program I wrote that converts Fahrenheit to Celsius:
function FahrToCelsius(f)
real FahrToCelsius
real, intent(in) :: f
FahrToCelsius = 5.0 * (f - 32) / 9.0
end function FahrToCelsius
program FahrenheitCelsius
real FahrToCelsius
real, parameter :: low = 0.0
real, parameter :: high = 100.0
real, parameter :: step = 10.0
real f, c
f = low
do while (f /= high)
write(*, fmt="(F8.3)", advance="no") f
c = FahrToCelsius(f)
write(*, fmt="(F8.3)") c
f = f + step
end do
end program FahrenheitCelsius
Fortran is both manifest and implied type, statically typed, and strongly typed. If a variable is not declared, Fortran will try to guess it’s type from it’s value, and this can be annoying because it’s not actually a dynamically typed language. Anyways, we define a function and call it in our main program. In the function, we declare our variables. real is a floating point, intent(in) means that f is an immutable input from the caller. At the main program we declare variables and then proceed with our executable code. A parameter is a constant. Fortran differentiates functions from subroutines (or procedures, here the terms may be used interchangeably). Functions return one value while subroutines return an arbitrary number of values. Fortran also has a lot of built-in functions for math. abs, sin, cos, tan, and more are included. Fortran can be incredibly fast for computation, even faster than C. This, along with built-in support for complex numbers, makes Fortran useful as a FORmula TRANslator.
However, this language is weird. It has a complicated type system. You have to declare variables, but you don’t have to, which confused me. So I invoked the -fimplicit-none flag on the compiler so it would force me to declare all my variables. Making subroutines and functions can be unnecessarily complex. To get arguments from a call, they must be declared within the code block along with the intent declaration. To get an immutable argument from the caller use (in), or (out) to make an outgoing argument. Wait, an outgoing argument? Yes, it’s a subroutine argument that is used for assignment. There’s also arguments that can be read from and written to. This was all very confusing for me.
Main Program:
integer a, b, c
a = 1
b = 2
call subroutine(a, b, c)
Subroutine:
integer, intent(in) a
integer, intent(inout) b
integer, intent(out) c
modify b and c
So, a can only be read, b is like a normal variable and c is undefined before being assigned. I call this “return values by assignment”. Rather than using a return statement (though there is a return statement, it is only used for exiting a subroutine), variables are returned to their callers by modifying variables that have been declared by their caller. On top of that, Fortran supports nesting functions and subroutines inside the main program and other subroutines and functions. This is standard, but usually not necessary for imperative languages.
Anyways, there are some other details about the language. Fortran has arrays and strings, and supports organizing code across files via modules. Modules are accessed in a way far more intuitive than C headers (Fortran compilers allow you to use the C Preprocessor if you wish). You can pick and choose the exact subroutines and functions you want to use for your code from a specific module or you can use the entire module. Let’s look at a summary of my take on Fortran.
Pros:
- Straightforward, procedural design
- Lots of built-in math operations
- Fast execution
- Built-in complex type
- Intuitive I/O routines
- Does it’s job as a language for calculations
Cons:
goto/archaic statements
- Manifest and implicit typing can be very confusing
- Functions and subroutines are unnecessarily complex
- Two dialects (fixed-form and free-form) can make Googling difficult
The verdict here is Fortran accomplishes it’s goal of being a language for scientific purposes. Personally, I would not mind using this language, though I probably wouldn’t choose it for any purpose. It’s amazing how a language that is so old has been able to adapt to the changes in computing. I had a pretty fun time learning this language, despite some of its nuances. Anyways, if you’ve used Fortran, feel free to give me your opinions of the language.