3 ms·
I have not kept up with recent developments, but Fortran has historically been noticeably faster than even C/C++ for numerical computations. This difference use
by ojnabieoot 6y ago
I have not kept up with recent developments, but Fortran has historically been noticeably faster than even C/C++ for numerical computations. This difference used to be quite stark due to limitations in C itself: http://www.ibiblio.org/pub/languages/fortran/ch1-2.html http://www.ibiblio.org/pub/languages/fortran/ch1-2.html (see " b) The design of FORTRAN allows maximal speed of execution:") I think things have gotten better in C, e.g. with C99's "restrict" keyword, along with general improvements in C compilers, but for a long while Fortran had a clear upper hand when it came to allocating and manipulating large arrays of floats. Outside of the language specification, I would wager that many supercomputers have better-optimized Fortran compilers than C compilers for this reason. And even if in principle C and Fortran can execute equally performant numeric code, Fortran's historic superiority has created a great deal of high-quality legacy Fortran code that nobody feels an urgent need to port into C (which would be tedious, expensive, and risky work).
In the modern day: R uses a standard Fortran BLAS implementation, as do many other libraries and platforms (NumPy, Numerics.NET, etc). LAPACK is also widely used for low-level numerical linear algebra: https://github.com/Reference-LAPACK/lapack https://github.com/Reference-LAPACK/lapack Intel also maintains a BLAS implementation. So there's still a healthy need for a (small) community of Fortran programmers, it's not all about maintaining 70s legacy code. Very different than the situation with COBOL.
- gnufx 6y agoIf you use the reference BLAS routines that ship with R, you're losing an order of magnitude serial performance on relevant operations. (The majority of Intel MKL surely isn't written in Fortran, like OpenBLAS and BLIS.)
- gnufx 6y agoAspects of Fortran favour it over C even when restrict is used, e.g. as mentioned in https://news.ycombinator.com/item?id=23124451 https://news.ycombinator.com/item?id=23124451
- jjdredd 6y ago> Fortran has historically been noticeably faster than even C/C++ for numerical computations Nowadays: faster - maybe, noticeably - I doubt it. > supercomputers have better-optimized Fortran compilers than C compilers I don't know about supercomputer compilers but mainstream compilers usually have the same backend for FORTRAN and C (as well as other implemented languages). > created a great deal of high-quality legacy Fortran code that nobody feels an urgent need to port into C Optimized and tested FORTRAN code - maybe, but not high-quality. I've seen some of it, FORTRAN makes it difficult to write readable, maintainable code. For this reason even scientist are rewriting their tools and libraries (that also require good performance) in C++: for example see Pythia, GEANT, cern root.
- walshemj 6y agoNot Shure that using c++ is going to help with "readable, maintainable code" any more than modern Fortran is. and I suspect they will be writing Fortran in C++
- jjdredd 6y agoCould be, at least C++ has tools to implement better design. I've seen one guy's python code that looks worse than his FORTRAN code. There's a russian saying: "A true FORTRAN programmer can write FORTRAN code in any language".
- greglindahl 6y agoAre you sure you aren't being polluted by this article? https://www.pbm.com/~lindahl/real.programmers.html https://www.pbm.com/~lindahl/real.programmers.html > Besides, the determined Real Programmer can write Fortran programs in any language.
- jjdredd 6y agoHeh, I could have made a mistake about the origin of the saying. I haven't read that article.
- walshemj 6y agoHeh I have worked on Nuke simulations for a breeder reactor so a mommy bomb and I have written Billing systems in Fortran. And that billing system was very well designed using map reduce back in the early 80's, we did have an actual genius as a team leader though.
- neurostimulant 6y agoThe thing is, you can write a perfectly normal fortran code, and instantly gain speedup (CUDA, distributed computing with OpenMP, etc) just by enabling some compiler flags. You can't do this in C/C++ as you have to deliberately write your program to use those tech. Also, vector/matrix operations are first class in fortran and you don't need to rely on 3rd party libs.