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.

Erik Engheim
CodeX

--

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:

  1. No explict type information is written anywhere. A lot of people think Julia performance comes from type annotations. Not true.
  2. 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.

--

--

Erik Engheim
CodeX

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.