|
|
|
|
|
by wisty
4787 days ago
|
|
Fortran is far from extinct, because scientists often prefer it to C/C++, and it's often faster. Part of the reason is that Fortran passes arrays by value, while C passes them by reference. It's very hard for compilers to optimise a pass-by-reference array, because it might have the memory altered by another part of the program. If it's pass by value, then you know it's safe. It's kind of like threads vs messages. I think C has some recent work done to close the gap, but even if it's already as fast, it will take a while to port 50 years of legacy numerical code. |
|
Actually, the reason is that Fortran arguments may not alias (passing big arrays by value would be horribly inefficient).
Btw, one of the main goals of C99 was making C a better language for numerics (ie catching up to Fortran): The restrict qualifier was introduced (mainly to mark non-aliasing parameters) as well as complex numbers, variable-length arrays and type-generic math functions.