Fortran is still a thing

Written by okaleniuk | Published 2017/05/07
Tech Story Tags: programming | software-development | fortran | software-engineering

TLDRvia the TL;DR App

There is an updated version of this post: https://wordsandbuttons.online/fortran_is_still_a_thing.html

Last week NASA announced a code optimization competition. There is a Navier-Stokes equations solver used to model aerodynamics, and basically, the one who makes it run the fastest on the Pleiades supercomputer wins the first prize.

There are few caveats though. The applicant must be a US citizen at least 18 years of age, and the code to optimize is in Fortran.

Fortran is not the most popular language in the programmer’s community. Many believe that it’s complex and outdated. Programming in Fortran is perceived like riding a horse-driven carriage to work. Fortran? Isn’t it something that Amish do?

It is not, of course, outdated, and it’s not at all complex. In fact, it has grown into these myths exactly because it is that good it what it does. It was designed to make number-crunching easy and efficient. Its users are scientists and engineers; not computer scientists and software engineers, but the real ones. And when engineers have a tool for the problem, they solve the problem with the tool. The problem comes first, not the code.

That’s how the complexity myth has started. Most of the code you see in Fortran is indeed complex. But this is because:

a) the problem behind it is complex;

b) the code was written by a domain specialist and not a programmer.

Fortran is simple enough for domain specialist to write bad code and achieve good results with it.

And as for the outdatedness, the last Fortran standard is only 7 years old. The next one is expected to arrive next year. It is constantly being modernized one little step after another. The biggest holding factor here is its mission. It must remain simple for real engineers.

However, the modern Fortran already has modules, objects, generics and built-in support for parallel computing. Foot shooting area is growing steadily to meet the fiats of a modern world.

It also excels in the good old structured programming. It has features that mainstream C-like languages lack. For instance, it can exit or continue a loop from a nested loop.

rows: do i = 1, 10columns: do j = 1, 10if (a(i, j) = 0.) exit rows...enddo columnsenddo rows

If has case statement with ranges.

integer :: temp_c

! Temperature in Celsius!select case (temp_c)case (:-1)write (*,*) ’Below freezing’case (0)write (*,*) ’Freezing point’case (1:20)write (*,*) ’It is cool’case (21:33)write (*,*) ’It is warm’case (34:)write (*,*) ’This is Texas!’end select

And it can use array of indexes to access another array.

real, dimension(5) :: a = [ 2, 4, 6, 8, 10 ]integer, dimension(2) :: i = [ 2, 4 ]

print *, a(i) ! prints 4. 8.

There is a brief introduction into modern Fortran by Lars Koesterke. If you think Fortran hasn’t changed since the 60s, please look through it. You might get surprised.

So Fortran is not complex and it’s not outdated. Now how come it went underground in the modern world?

The answer here is actually the same as for “where do old programmers go?” They mostly stay in business, but according to Martin’s lawn, as the number of programmers doubles every five years, they get vastly outnumbered by the younger folks. They just dissolve in a mass. But this is endemic for software industry only. Fortran users are mostly the real engineers and their number doesn’t grow exponentially. So there are basically the same amount of Fortran users, old and young, as it was some 30 or 40 years ago when Fortran was at its peak.

In a way, it has been at its peak all that time. It’s the world around that has gone crazy. Languages come and go, paradigms ripe and rot, the whole software business is a part of fashion industry now. But when you want your plane to fly, you still need to do the maths with your trusty Fortran. That’s the beauty of the things that work; they don’t have to change much.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!


Published by HackerNoon on 2017/05/07