4 ms·
Fortran is the language of high performance computations because it forces programmers to use static memory layout, and has real arrays. It is easier to emit (S
by hebdo 11y ago
Fortran is the language of high performance computations because it forces programmers to use static memory layout, and has real arrays. It is easier to emit (SSE-)vectorized assembly from Fortran code than from C. You can of course achieve the same effects in C as you can in Fortran, but by default it requires more knowledge. For example not many people are aware of the "restrict" C keyword, which is absolutely necessary to write vectorizable code.
JavaScript is incomparably slower than Fortran. Also, Fortran has been fast since day 0.
Edit: I've just found out that "restrict" has been added in C99. Which means that even in the 90s there was no good support for parallel/vectorized code in the C standard.
- nickpsecurity 11y agoGood points. I'll add that the compiler can have more difficulty understanding what's going to happen with C code compared to Fortran code. This affects how easily and much optimization can happen. Sometimes less is more.
- tanderson92 11y agoYou mean day 1, Fortran uses 1-based array indexing (by default, it is configurable for each array declaration!) ;-) edit: Variable Length Arrays (VLAs) were also not available until C99 for C, while they were part of Fortran since 1990.
- rootbear 11y agoAnd in C11, I believe they are now optional. EDIT: Oh, and kudos on the day 1 vs day 0 comment; very funny!
- teamonkey 11y agoI didn't mean that JavaScript is in the same performance category as Fortran, just that they've both had an above-average amount of investment in performance. There are certain aspects to FORTRAN that naturally lend it to being fast but you still need to write it in a way that can be optimised, which isn't always the most obvious way. You need to know the language and compiler well to wrote fast code, just as you would with any other language.
- noobermin 11y agoIf C++ would implement something like restrict (in the standard), we could hide it in the usual C++ way and may be a very performant library with all the benefits of C++ could become feasible.
- leoc 11y agoApparently Dennis Ritchie was set against adding even user-optional features to address C's performance limitations versus Fortran ("If you want Fortran, you know where to find it.") I think that's (at least partly) why they started showing up in C99, after the first round of standardisation which he wasn't involved with.