Why abandon Fortran for Linear Algebra?

Regarding how to message about Fortran:

and:

Indeed, I think it depends who we are speaking to:

  • Existing Fortran users of a big production codes who are forced to migrate to C++ for technical and social reasons: They already know Fortran, and so I feel it is crucial to admit that unfortunately we are coming short of Fortran’s potential and that the reasons to migrate are real. If we say “you have no reason to migrate”, then that I find very “tone deaf” and it only accelerates the migration away from a language whose developers can’t even admit its shortcomings. For this group I feel the following messaging at the end of my post here is optimal: Why abandon Fortran for Linear Algebra? - #6 by certik

  • New users: For this group I feel it is not optimal to talk about all our problems, but rather we should advertise the strengths and there are many.

We should develop a good strategy to advertise Fortran.

4 Likes

Apparently @Mason is much younger than me :slight_smile: , I can talk from the side of the advisor. My recent move from Fortran to Julia has different motivations:

  1. I had to start learning Python to produce plots and analyze data. I detest the fact that with Python I have to adapt the algorithms to the language to “vectorize” everything to get reasonable speed. Not mention that Python syntax is not for what I do (numerical computing), and is way behind Fortran and Julia syntax in that aspect.

  2. I came to know Julia some years ago when it was on version 0.6 I think, but that was too early for me. I still produced one relevant package in Fortran (using some more modern concepts, as custom types) since then. But my contact with modern Fortran was very modest.

  3. When Julia 1.0 appeared I decided to give it a serious try and develop a more involved project. It was already a nice user experience, and I got hooked.

  4. I do feel somewhat uncomfortable “forcing” my students to learn Fortran. I do not see where they would use in daily life. Most of what they do are small programs for data analysis within their projects. They do not need long-term stability. The natural language for them would be Python, probably, but I think that learning Python is bad for student computer programming education. I have constantly to make them break the programming mental model that they learned with Python so that they can write performant code and not waste hours and hours of time trying to invent some way to use libraries for tasks that can be solved with simple loops and conditionals. Because of that I had never switched to Python or to any other interpreted language except for very superficial things.

  5. I do feel somewhat uncomfortable “forcing” them to learn Julia, because that is not what the market expects of them mostly. Yet, at least they can use it for scripting as well as for learning more advanced programming concepts (or even the simpler ones, as loops) that are necessary for high-performance numerical computing. Migration from something like Julia to something like Fortran or to something like Python will be a smooth path on both sides.

  6. Distributing my packages in Fortran has always been sort of a headache. Yes, we can distribute binaries, but many of my Windows users don’t know what to do with a binary. They double-click the thing and they want something to appear. They won’t use a Shell. As stupid as this might seem, telling them to install Julia from the site, double-click on it and install my package is easier…

From the point of view of a young programmer which probably won’t be involved in any massive/critical development, Julia syntax is very clean. In my opinion Matlab has no reason anymore to exist, except legacy. And I think Fortran should look at Julia for inspiration and joining forces. A function like this in Fortran:

(fixed) as pointed by @themos:

double precision function f(x)
  double precision :: x
  f = 2*x
end

can be identically written in terms of performance and generality in Julia as:

function f(x::Float64)::Float64
  f = 2*x
end

except that in Julia I do not need to add those type annotations and I get a generic function “for free”:

function f(x)
  2*x
end

To write performant code in Julia one has to understand the mental model of the type-annotated Fortran function, to understand what is going on when one calls that generic function with one specific type of variable. It is a gain-gain learning experience.

My impression is that Fortran evolving to accept generic programming smoothly as Julia does makes almost Julian. If Fortran goes that path with all backward compatibility and stability it will survive much longer. It can be the stable and long-term reliable, compilable, version of something like Julia. I do think that both project could/should join forces as they target in a great deal the same user base, and have already a lot in common.

7 Likes

Thank you for these thoughts, @septc. I was delighted to discover today that Lahey provide a source checker for f90/f95 code at Lahey - Fortran Source Check, a bold move.

1 Like

I don’think “return 2*x” is Fortran😃

3 Likes

Yeah… already mixing languages :slight_smile:

2 Likes

It seems Intel decided to make their compiler free from now on.
Intel Fortran + MPI is free now, it is called Intel® oneAPI Toolkits
It is a good thing for Fortran!
If I remember correctly, they have a beta version of Fortran called IFX or something, perhaps support interactive interface.

I don’t think so – maybe you are thinking of LFortran. IFX will be analogous to what they have done with their C and C++ compilers:

https://software.intel.com/content/www/us/en/develop/blogs/adoption-of-llvm-complete-icx.html