3.1 Multiple Dispatch

There is no one better to talk about the idea Multiple Dispatch and its use in Julia than Stefan Karpinski. In a 2019 JuliaCon talk titled “The Unreasonable effectiveness of Multiple Dispatch” (https://youtu.be/kc9HwsxE1OY), Stefan went on to state that the Julia ecosystem has more code re-use than any ecosystem he has ever seen. Multiple Dispatch is the paradigm that allows this to happen. So what is Multiple Dispatch and why is it so unreasonably effective? For the latter point, I suggest watching Stefan’s talk, there is no sense in re-stating what he already put eloquently. So back to the main question, what is multiple dispatch? The main idea here is that you can write multiple functions with the same name, which dispatch (or are called dynamically) depending on the types of the input arguments. This idea is not something necessarily unique to Julia, other languages have multiple dispatch or similar concepts. But the way in which it is used and implemented in Julia is the secret sauce. Let us now look at a quick example:

CC BY-NC-SA 4.0 Logan Kilpatrick