Why doesn't Julia allow multiple inheritance?

This has certainly been discussed as a possibility. I think Jeff Bezanson might have mentioned this in a talk in JuliaCon 2017 (possibly this talk - JuliaCon 2017 | The State of the Type System | Jeff Bezanson - YouTube).

It’s taken a fair bit of effort to get a typing system with an accurate subtyping algorithm that combines

  • An (abstract) single-inheretence tree
  • Invariant type parameters (either types with upper/lower type bounds, or constant values)
  • Covariant tuple type parameters (we happen to allow values here too)
  • Tuples of variable numbers of arguments (Varargs)

For a view into the complexity required to achieve all this, see this JuliaCon 2018 talk: JuliaCon 2018 | Subtyping made friendly | Francesco Zappa Nardelli - YouTube

My observations are that we’re at the stage where the language has been moving fast and we’d possibly like to consilidate a little before considering major changes to the type system. The open questions here are whether we move towards multiple inheretince, interfaces, traits, etc - and what are the design/implementation tradeoffs of each of these?

For the moment, as mentioned, using traits in an explicit manner (“Tim Holy traits”) lets you handle basically any type “inheretence” model you could possibly want (as far as I can tell, anyway).

7 Likes