The Unreasonable Efficiency and Effectiveness of Multiple Dispatch: Your Favourite Examples

I know this thread is asking for examples, but an earlier post of mine about composability not being novel was represented as a caveat of preaching multiple dispatch. I disagree, doing familiar things easily is actually a very good reason for preaching features, like garbage collection for managing memory. A couple general aspects I like:

  1. Julia can’t have a discrepancy between a compile-time expression’s inferred concrete type and runtime instance’s type, so there’s no syntactic division between static dispatch and dynamic dispatch. If we optimize a dynamic dispatch to a static one, it’s only a matter of improving type inference in the actual algorithm, not a reformatting exercise.
  2. When flexible dynamic dispatch is only available as single dispatch, people can resort to making many composite types just to merge the multiple arguments that they can’t dispatch over. Obviously discouraged, but deadlines don’t wait for refactoring.

Julia’s multiple dispatch alone doesn’t explain the way it accomplishes composability, but reducing mental load sure doesn’t hurt.

3 Likes