4 ms·
Well, lots of languages have mixins or traits, which is pretty similar. Also multiple inheritance got a bad rep through C++'s particular implementation of it, b
by skrebbel 10y ago
Well, lots of languages have mixins or traits, which is pretty similar. Also multiple inheritance got a bad rep through C++'s particular implementation of it, but it doesn't need to get so messy.
Eiffel, for example, a language that nobody uses but that people like me love to discuss in OO related debates, has much simpler and better support for multiple inheritance: If theres any clash of methods (name+signature) from different parents, you must choose which one the child class gets or it won't compile.
Im not sure what Nit does, but it might not be as brain dead as waht C++ does.
Finally, I prefer composition over inheritance too, but on the other side many of my React components have multiple mixins. I couldnt do that if I had used ES6 classes. Given that Nit seems targeted at UIs (android, obcj support), I guess it makes a lot of sense.
- olalonde 10y agoCan't you have "mixins" with ES6 classes by decorating them (e.g. applying a function to the class which adds the desired behaviour)? Related ECMAscript proposal which adds some syntax sugar: https://github.com/wycats/javascript-decorators https://github.com/wycats/javascript-decorators
- skrebbel 10y agoYeah sure, but my point is not about how flexible JS is or isn't, but about how multiple inheritance is a good fit for certain areas, such as UI code.
- keyle 10y agoThanks skrebbel :)
- skrebbel 10y agoNo problem keyle :)