Overhead of modern Fortran features

Well, it’s definitely slower to compile, because the compiler must do a little more work. But I think if implemented well, the overhead is not large.

Regarding the speed of the generated code, if you don’t use OOP, you won’t pay any performance hit. I think that is true for all compilers.

If you use OOP, then it just depends on the actual algorithm. It’s like asking if C++ classes are slower than C raw pointers. Well they can be if you use them inefficiently, but if you use them correctly, the performance is comparable. (That being said, for LFortran I benchmarked classes with inheritance vs raw C structs for the internal AST representation, and the C structs with manual type information turned out to be slightly faster. But it likely also depends on the compiler and our use case is very specialized. For most applications the performance is comparable.)

Finally, a lot of modern features make your code potentially faster, such as coarrays or do concurrent.

3 Likes