Well of course Julia doesn’t necessarily win. There’s a way to rewrite the C or Fortran algorithms here to get it as fast as the Julia version. I don’t think anyone would argue that. But I think it’s safe to say that Julia’s optimizations may actually beat a lot of scientist’s ability to “hand optimize” C/Fortran code. And what you get in return is something that is much more concise which then makes it easier to add all the bells and whistles. You can probably dig into the Fortran code here and pull out another 10%, but in the Julia version you can add Threads.@threads
and maybe add PI adaptive timestepping in 20 lines and end up with something orders of magnitude faster, still ending up with more concise code. That’s why Julia does well.
And actually, if Julia gets an @noalias
macro for creating local scopes which guarantee arrays aren’t aliasing (or something like volatile
), Julia could probably match the last few compiler optimizations which require the absence of aliasing. At that point it probably comes down to which compiler is used more than anything else, and gcc vs clang/LLVM seems to be a toss up: usually very similar, but in some problems one or the other “wins”, but you can never guess which one (and when asking people to recompile whatever reference C code via clang and checking the timing difference actually accounts for most benchmark variation from what I’ve seen, i.e. the difference between C and Julia usually is mostly measuring a difference between gcc and clang on that algorithm).