Sunday, July 07, 2019

Fortran is underated!

(Joint Post with David Marcus who was a classmate of mine at SUNY Stony Brook [now called Stony Brook University]. I was class of 1980, he was class of 1979. We were both math majors.)

David has been reading Problems with a POINT (I'm glad someone is reading it) and emailed me a comment on the following passage which was essentially this post. I paraphrase what I wrote:

PASSAGE IN BOOK:
I dusted off my book shelves and found a book on Fortran. On the back it said:

FORTRAN is one of the oldest high-level languages and remains the premier language for writing code for science and engineering applications. (NOTE- The back of the book uses Fortran but the spell checker I am using insists on FORTRAN. As a fan of capital letters, I don't mind going along.)

When was the book written?

The answer was surprising in that it was 2012 (the Chapter title was Trick Question or Stupid Question. This was a Trick Question.) I would have thought that FORTRAN was no longer the premier language by then. I also need to dust my bookshelves more often.
END OF PASSAGE IN BOOK

David Marcus emailed me the following:

DAVID'S EMAIL
Page 201. Fortran. One clue is that it said "Fortran" rather than"FORTRAN". Fortran 90 changed the name from all upper case. Whether it is the "premier language" depends on what you mean by "premier". It is probably the best language for scientific computing. I used it pretty much exclusively (by choice) in my previous job that I left in 2006. The handling of arrays is better than any other language I've used. Maybe there are some better languages that I'm not familiar with, but the huge number of high-quality scientific libraries available for Fortran makes it hard to beat. On the other hand, I never wrote a GUI app with it (Delphi is best for that).
END OF DAVID'S EMAIL

In later emails we agreed that Fortran is not used that much (there are lists of most-used languages and neither Fortran nor FORTRAN is ever in the top 10). But what intrigued me was the following contrast:

1) David says that its the BEST language for Scientific Computing. I will assume he is right.

2) I doubt much NEW code is being written in it. I will assume I am right.

So---what's up with that? Some options

OPTION 1) People SHOULD use Fortran but DON'T. If so, why is that? Fortran is not taught in schools. People are used to what they already know. Perhaps people who do pick up new things easily and want to use new things would rather use NEW things rather than NEW-TO-THEM-BUT-NOT-TO-THEIR-GRANDMOTHER things. Could be a coolness factor. Do the advantages of Fortran outweight the disadvantages? Is what they are using good enough?

OPTION 2) The amount of Scientific computing software being written is small since we already have these great Fortran packages. So it may be a victim of its own success.

CAVEAT: When I emailed David a first draft of the post he pointed out the following which has to do with the lists of most-used programming languages:

DAVIDS EMAIL:
The problem with the lists you were looking at is that most people in the world are not scientists, so most software being written is not for scientists. Scientists and technical people are writing lots of new code. If you look at a list of scientific languages, you will see Fortran, e.g., here and here.


There are several Fortran compilers available. One of the best was bought by Intel some time back and they still sell it. I doubt they would do that if no one was using it. Actually, I think Intel had a compiler, but bought the Compaq compiler (which used to be the Digital Equipment compiler) and merged the Compaq team with their team. Something like that. I was using the Compaq compiler around that time.
END OF DAVID's EMAIL

One quote from the second pointer I find intriguing. (Second use of the word intriguing. It was my word-of-the-day on my word-calendar).

... facilities for inter-operation with C were added to Fortran 2003 and enhanced by ISO/ICE technical specification 29113, which will be incorporated into Fortran 2018.

I (Bill) don't know what some of that means; however, it does mean that Fortran is still active.


One fear: with its not being taught that much, will knowledge of it die out. We be like Star Trek aliens:

The old ones built these machines, but then died and we can't fix them!



7 comments:

  1. As long as documentation lives, knowledge about how to program in Fortran can be recovered. Of somewhat greater concern are binaries that were patched at the binary level, and no longer correspond to their original source code. Yes, such things exist! In those cases, when the underlying architecture dies (and I'd expect a lot of this with the 32->64 transition), those codes die too, except perhaps in emulation.

    FORTRAN (and it was all caps in those days) was the second language I learned, in a self-taught programming class at Michigan State circa 1976. Whatever its merits as a scientific programming language, it had weak data and control abstraction, and so is not a language I'd be eager to chose today. Programmer productivity matters too.

    ReplyDelete
    Replies
    1. Fortran 90 is a big change from FORTRAN 77.

      Delete
  2. Out of curiosity, I went ahead and searched stackoverflow for recent FORTRAN questions. Given that many more people read stackexchange questions and answers than writing those, there seem to be quite some people interested in FORTRAN: https://stackoverflow.com/search?tab=newest&q=fortran
    The interest may not be comparable to that of modern languages like JavaScript, Go or Rust. But I would be curious whether more questions are asked about FORTRAN than about theoretical computer science at stackexchange sites ;-)

    ReplyDelete
  3. As far as I know, as of today, THE language for "scientific computing" is Python. By itself it is slow, but it has widely used and well performing libraries such as NumPy and SciPy for linear algebra and other mathematical calculations. One has to say that even using these, you will probably not squeeze your CPU till the last flop - but does one really need to?
    What is more important, Python has a huge user base, lots of libraries and a reasonably solid "ecosystem" (IDEs, packaging etc).

    ReplyDelete
  4. Hey, so I'm not sure what really triggered
    or who really "inspired" the pivot to the topic
    programming languages, but fine.
    With this choice of topic, you have once again opened up a
    big box - hopefully not Pandora's box. Frankly, I'm surprised
    by how little feedback you got for it. I'd hoped it would have
    sparked more comments.

    Basically, depending on from what era you come from,
    what you want to compute, and how efficiently you
    want to compute it, FORTRAN could be your choice of programming language.

    NASA is still actively using it; and so are some other companies
    that for good reason stay in stealth mode and don't reveal
    what is actually being used to perform computation.

    Interestingly, the topic is missing older languages that have
    been used for scientific computation, in particular, AI.
    The wiki link about "Scientific programming language" also misses those. Wiki can't really be trusted to be a fully fledged out reference source; due to the commercial companies whose purpose is to fabricate and actively manipulate these entries to their advantage, either directly or through "their" friends and
    puppets.

    There's more to be said, here but I'll leave it at that.

    ReplyDelete
  5. There is a reason why some of the most destructive (of life or property) software bugs of all time were in FORTRAN. The language has very poor -- today, probably uniquely poor -- resiliency against coding-time errors (slips of the finger). This is not something that can be ameliorated by "better" compilers; it is inherent in the language. Object-oriented languages can be used such that errors of syntax OR OF LOGIC will result in the software failing to compile, therefore bad software can never be run because the exectuable artifact does not even exist.

    ReplyDelete
    Replies
    1. In my experience, lots more typos are legal syntax in C++ than in Fortran. Fortran 90 introduced many features to let the compiler catch typos. In particular, the compiler could check that you were passing the correct arguments to procedures and functions. Fortran 2003 introduced objects.

      Delete