I am working on a program language, and I came to the dilemma whether it should support virtual inheritance or not.
As a designer and implementer of the language, including that feature represents added complexity.
As a language agnostic software developer, it seems like the only benefit from including it is to facilitate and allow bad software design.
The cases I encountered where virtual inheritance is utilized all seem to be better candidates for "add-on" interfaces.
Of course, I do recognize that working with existing 3rd party code you don't have control over is definitely something that might mandate the support for virtual inheritance.
But for me this is not the case, I have a clean slate, and full freedom to define the paradigms and idioms of the programming language. Therefore the more elegant and efficient solution seems to be to simply eliminate the possibility that the need for virtual inheritance might arise and omit the feature altogether.
I also notice that it is a rather niche feature, of the several languages I have studied, C++ is the only one to support it. Leading me to presume it is not all that essential.
Naturally, I might also be overlooking something, which prompted me to probe the developer community for input on the subject.
EDIT: To clarify as requested, performance and memory efficiency are some of the primary goals of the language. Virtualism, dynamism and any high level programming functionality is optional and only included if necessary. It is not a language where everything is references and virtual calls.
Instead of
class WingedAnimal : extend Animal {}
my current plan is to avoid the need to address member duplication by means of
class WingedAnimal : require Animal {}
which essentially allows WingedAnimal
to use Animal
without inheriting it, guaranteeing that any users of WingedAnimal
will be compatible.
my $btn = $dlg->Button( %some_parameters );
No need to create a class MyDialogButton which inherits from the Button class. Ever button is an object of the Button class; it just their parameters that cause different behaviour.car.start()
rather thancar.vehicle.start()
. For buttons that is extreme overkill, I favor the solution where buttons use signals to implement the desired functionality rather than to subclass each and every button. A subclass is only justified if you change the class or add to it. What a button does can and should be external code, not part of the button.