1 comment

[ 3.5 ms ] story [ 12.9 ms ] thread
The advantages of composition (or "true" delegation) over inheritance are well documented, but many languages remain poorly suited for it, particularly Java.

In the influential book "Effective Java" the author advocates favoring composition over inheritance, yet Java provides little support for it. One is left having to write or generate large portions of boilerplate code to achieve the most basic form of interface composition. More pragmatic support for the feature requires language/VM intervention, such as with true delegation and mix-in traits. This isn't to say the author's claims about inheritance and composition aren't well intentioned, however in practice it is difficult to make use of this advice when the language he champions, nearly a quarter century later, still does little to facilitate his position. The library mentioned here works toward a remedy[1].

1. https://github.com/manifold-systems/manifold/blob/master/man...