(no title)
DNF2 | 3 months ago
In performant Julia code, the compiler is not invoked, because types are statically inferred. In some cases you can have dynamic dispatch, but that doesn't necessarily mean that the compiler needs to run. Instead you can get runtime lookup of previously compiled methods. Dynamic dispatch does not necessitate running the compiler.
mccoyb|3 months ago
Perhaps there is something about subtyping which makes this answer ... not correct -- and if someone knows the real answer, I'd love to understand it.
I believe that this answer is because of performance -- if I can JIT at runtime, that's great -- I get dynamism and performance ... at the cost of a small blip at runtime.
And yes, "performant Julia code" -- that's the static subset of the language that I roughly equated to be the subset which is trying to be pried free from the dynamic "invoking the compiler again" part.
eigenspace|3 months ago
This is exactly what the new AOT compiler (juliac) does. The original article is just a bit inaccurate.
The problem though, is that if you have a truly dynamic call-site where you have no idea which method body will be called, then the AOT compiler can't know if the right method specializations will survive the trimming process, so you'll get errors or warnings when compiling with the --trim feature active (--trim is what is used to make the AOT compiled binaries small).
However, there are still lots of cases where you can have a dynamic dispatch but can convince the compiler that there will be an already compiled method signature for every possible specialization. In that case --trimm will work fine and do exactly what you described above.
DNF2|3 months ago
Anyway, performance in Julia relies heavily on statically inferring types and aggressive type specialization at compile time. Triggering the compiler later, during actual runtime, can happen, but is certainly not beneficial for performance, and it's quite unusual to claim that it's central to the performance model of Julia.
If you are asking why Julia allows recompiling code and has dynamic types, it's not for performance, but to allow an interactive workflow and user friendly dynamism. It is the central tradeoff in Julia to enable this while retaining performance. If performance was the only concern, the language would be very different.