JuliaCon 2025

MultipleInterfaces.jl: Multiple Inheritance & Multiple Dispatch
2025-07-24 , Main Room 1 (Main stage)

MultipleInterfaces.jl provides a powerful way to define and work with interfaces in Julia. With MultipleInterfaces.jl you can declare an interface that is defined by a list of required methods, and you can declare which types implement that interface. Interfaces support multiple inheritance, interface intersection, and multiple dispatch. And all with no runtime cost. We will present the motivation for MultipleInterfaces.jl, how the package works, and an example application.


We present MultipleInterfaces.jl, a powerful way to define and work with interfaces in Julia. With MultipleInterfaces.jl you can declare an interface that is defined by a list of required methods. An interface can inherit from one or more interfaces. The support for multiple inheritance of interfaces allows the expression of complex hierarchies of interfaces. Optional interface methods are no longer needed because optionality is expressed through the DAG of interfaces.

In addition to multiple inheritance, MultipleInterfaces.jl provides an enhanced version of multiple dispatch methods. These methods can dispatch on traditional Julia types for some arguments and interfaces for other arguments. They even allow dispatching on the intersection of interfaces, like Iterator & Table. And all this comes with no runtime penalty.

We begin by providing an example of a hierarchy of graph types that motivates the need for multiple inheritance. Next, we show how to define interfaces, how to declare implementors of interfaces, and how to define methods that provide multiple dispatch on interfaces. Finally, we describe how to resolve the issues with the graph type hierarchy by replacing it with an interface hierarchy.

Cameron is a data scientist with interests in physics, engineering, and mathematics, and of course well designed Julia libraries.