There might well be good answers to these; but it seems that if you want to make Fortran cool again, you have to provide a vision for what makes it special.
There might well be good answers to these; but it seems that if you want to make Fortran cool again, you have to provide a vision for what makes it special.
A physicist or engineer, already being familiar with Matlab or Python, can pretty much pick up Fortran in about 2 days to 1 week, get to be productive, and the compiler will generally generate fast code. Try to teach C++ to a domain specialist, who doesn't have too much extra time to study programming language syntax and quirks, because their main motivation is working in their domain?
If the scientific code was in C++, some scientists would probably never become fluent enough, and the workflow would probably deviate towards a division where scientists prototype their ideas in Matlab or Python, and separate technical programmer personnel implement it in the production code. The turnaround time from ideas to seeing results would be days instead of hours.
I see two reasons why C++ is not a suitable language for domain specialists in numerical computing.
1. Programming in C++ requires a certain discipline to understand what is going on, for example to not accidentally make useless copies of huge arrays. In fortran you do not need to learn such a discipline because everything is explicit.
2. Fortran natively supports multidimensional numeric arrays. In C++, not really; you need to use "libraries" whose evolution is independent to that of the language and may become unsupported. A few years ago, everybody said to use "blitz", somewhat later it was "eigen", now it probably is something new. The C++ numerical code that you may write today will probably be obsolete in a few decades. Yet the fortran code will be alright. It is "eternal".
That being said, the learning curve for someone not familiar with C++ to write code using Eigen is much higher than writing the same code in Fortran. If you're not already a C++ programmer, you just want to do some math, and Numpy/Matlab are too slow or constrained, then Fortran is a solid choice.
Moreover, the algorithms implemented inside eigen are hidden behind dozens of onion-like layers. Once you peel all these layers you find code such as this:
https://eigen.tuxfamily.org/dox/JacobiSVD_8h_source.html
I can read and write C++ and I teach numerical linear algebra for a living, but mother of god, this SVD implementation is horrendously unreadable to me. Most of the lines of code are stupid bureaucracy necessary just to add and multiply a few vectors. The same algorithm in linear algebra textbooks requires about fifteen lines of pseudo-code, and similarly for a fortran implementation.
The positive side of this is that it enables nice interfaces for the library, and makes a lot of the abstractions basically "free" (since the cost is paid at compile time rather than via pointer indirection at runtime). But it definitely makes those libraries inappropriate for students who want to look at an understandable implementation of the algorithm.
Maybe it is just me, but I do not really see the need for "abstractions" in a linear algebra library. Numbers are already an abstraction, you do not want to hide them! Ok, maybe you want to choose between "float" and "double", but this does not merit all that overcomplication.
This logic is omnipresent in Eigen and is crucial to its performance. It is also used to have specialized versions of some decompositions when the matrix's size is known at compile time.
The advantage of Fortran is that the code is simple and comprehensible to average scientist, and yet fast, because the effort goes into the compiler itself. I would also argue it is easier to implement an optimization pass in the compiler than implement optimizations on the template level in C++. The disadvantage is that you need a good Fortran compiler. If your compiler can't run your code on, say, GPU, then suddenly there is not a good path forward. While in C++, there is always a way forward via template metaprogramming: perhaps ugly, but at least it gets the job done.
Have you heard of MPI or even OpenMP ?. They can be used to accelerate fast computation in C++ or even work on domain-specified parallel execution.
these features are also available in fortran since forever
Fortran is a language more suited for numerical computing than C++. Modern Fortran is simpler, more maintable and more easily optimised than C++. Yes one could pick a subset of C/C++ and write fast numerical code but it would require more work and more discipline than using modern Fortran.
Last time I think I saw any action was the heated debate about goto:s in the style guide ;)
Fortran does not need Scott Meyers. And that's a good thing, because those who program in Fortran are typically not full-time software developers, they are individuals with other things to do that would not ever invest the time to write "proper" C++.
In the meantime, others in this thread pretty much hit all the main points already why Fortran as a language is still a very good choice for numerical computing. It's the tooling that must improve.
C++ is a messy, unsafe, and not particularly elegant systems programming language, which can be used for numerical computing, but it is not a good idea.
The new features of Fortran 2018 [pdf]