• ignirtoq@feddit.online
    link
    fedilink
    English
    arrow-up
    4
    ·
    8 days ago

    I learned about JavaScript’s prototype-based inheritance model a decade ago. It’s different from every other major language, but it’s interesting and useful when used the right way. I’m astonished (1) people are still rediscovering “optimization” techniques like are described in the article when that’s how their constructors should have been designed from day-one, and (2) the JavaScript language still hasn’t added more language features to make the mutated-prototype inheritance pattern less verbose and more ergonomic. It’s a core architecture of the language and hasn’t been improved, it looks like, since the first time I read about it 10 years ago. They added the whole class syntax sugar to hide the differences in the language’s inheritance model, so they can add some improvements to the syntax for the better optimized inheritance pattern.