The role of inheritance in Javascript's future

If we look deep into this language we can notice a lot of things that's rarely / not used at all; like with, switch, do...while, void, new.target... + now var.
I think these were some concepts that phased out overtime. Inheritance is a similar concept! FP made me realise that the major selling point of OOP wasn't classes, objects / inheritance but modularity and the dot notation (believe me people really do like dots😂, even so that this notation (OverloadedRecordDot) got added recently to Haskell!)
I'm optimistic about the future of JS. I'm seeing that it's decoupling itself from Java/C++ way of OOP into new future forward solutions. I can say this profoundly by quoting the proposals: maximally minimal mixins, records & tuples, static blocks, module blocks, defensible classes, orthogonal classes, ...
I endorse the mixin pattern which gives us best of both worlds - inheritance & composition (Reflect.mixin proposal). Generally I don't think OOP will ever vanish but just merge with FP to give us a solid programming model than the one we have today. Go & Rust are paving the way for this transition. Maybe even Object Oriented Optics - lenses & prisms and all that stuff currently seems terrifying in Haskell :joy: :joy:, or maybe not...

Sorry but I have to cross you on this one! knowingly or unknowingly we all use it in one form or other! Haskell uses it in typeclasses. JS simply won't be JS without it. Even in imperative C, there's multiple dispatch of functions, which inherently is inheritance! Agree it or not but inheritance is actually good for designing native APIs like DOM, and other browser APIs. And I think it's prime use should be restricted to such platforms. There's no simple answer for avoiding inheritance but I think most of the time composition or a preferable design pattern is at best. I really don't like abstract class man i.e in JS because it kind of seems useless / incomplete without static typing. Using inheritance model in built-ins doesn't seem very odd, as I said it's ideal for designing such APIs.

2 Likes