Comment by adrian_b
3 years ago
In the past, Fortran was always faster than C in scientific computation applications, mainly because many optimizations are prevented when compiling C, by the risk of pointer aliasing.
In modern C, such optimizations are possible by using "restrict".
Nevertheless, few C programmers bother to write "restrict" wherever it should be used, so casually written C code remains slower than similarly written Fortran code.
Moreover, modern Fortran has a lot of builtin operations for multidimensional arrays, which can be implemented in an optimized way by the compiler.
Writing simple C code cannot achieve a comparable effect.
Achieving a similar performance in C would require a special optimized library and this would result in extremely verbose and ugly C code. It is really impractical to do this in C and C++ must be used, with operator overloading, iterators and templates being needed to write a custom library that can match or exceed the builtin features of Fortran.
> Writing simple C code cannot achieve a comparable effect.
Can you provide a citation or source on this please?
I can't provide a citation or source either but I have seen such claims in a variety of places over the past 20 years. Certain design choices in C have caused the compiler to not be able to optimize as much as compilers for languages like FORTRAN or SISAL can. Of course, the ability to optimize SISAL was critical since it ran on the Cray supercomputers.