← Back to context

Comment by pkolaczk

3 years ago

It definitely misses some features that are considered bad: e.g implementation inheritance or memory handling by exceptions. Those are not essential for anything and are not planned.

>" implementation inheritance "

What authority declares implementation inheritance bad may I ask? As long as one does not stick it into inappropriate places it is actually very helpful.

  • 1. it can be always replaced with composition, which Rust already supports

    2. it comes with a non-negligible complexity cost to the language (e.g. what if you do multiple inheritance, what code gets called at object construction etc)

    You probably don't want to end up with a language that implements all ideas that are good in some context. Especially you don't want to have different mechanisms for achieving the same thing.

    • >"1. it can be always replaced with composition, which Rust already supports"

      This is no argument from my point of view. Everything can be replaces with simpler things. We are not going back to assembly however except very few cases.

      "2. it comes with a non-negligible complexity cost to the language (e.g. what if you do multiple inheritance, what code gets called at object construction etc)"

      Every feature has complexity costs and I prefer to have options here. It should be me who decides what I am willing to trade and what for.

      >"Especially you don't want to have different mechanisms for achieving the same thing."

      They're not exactly the same thing and actually this is exactly what I want. I am very averse of super opinionating "my way or highway" type of things. Oh and btw from a glance Rust seems to have different mechanisms for the same thing too, for example with all those option / unwrapping / question mark.

      The question was asked about "by what authority". Your arguments are just an opinion not any better than mine.

    • > it can be always replaced with composition, which Rust already supports

      Strictly speaking, open recursion (a notorious footgun in implementation inheritance, and arguably the underlying cause of the "fragile base class" problem) cannot be implemented via composition as-is. You need a complex "tie-the-knot" construction, typing "self" as an existential type defined in terms of itself, to enforce an indirection through the object's vtable in all calls to overridable methods. (AIUI, Rust does not have existential types that are general enough to allow this, albeit that might happen at some point as part of overall improvements to the type system.)