Is Julia Really Fast?
An overview of what you can and cannot expect from Julia performance. A guide to the fence sitters pondering whether to use Julia for high performance computing.
Published in
8 min readJun 19, 2021
It may seem hard to believe that a dynamic language can be fast, but Julia is really high performance in a way I think people have a hard time wrapping their heads around.
I explain this in detail in my ACCU 2021 conference talk: A Tour of Julia — Erik Engheim
But that is about 1.5 hours, so here is the quick rundown. I use a nonsense function in Julia just to demonstrate how highly dynamic code can be optimized in Julia.
function foo(xs...)
ys = map(xs) do x
T = typeof(x)
k = convert(T, 2)
c = convert(T, 3)
k*x + c*x
end
sum(ys)
end
It is not that important to understand exactly what it does. What I want to highlight in this code is a number of facts:
- No explict type information is written anywhere. A lot of people think Julia performance comes from type annotations. Not true.
- Optimization ought to be hard given that it has variable number of arguments
xs...
. How will a compiler know how to optimize? The number of args is only known at runtime.