3 ms·
I think it's almost like a challenge people do for its own sake because it's something even Crockford failed to do correctly. Write an awesome classical inherit
by Tloewald 13y ago
I think it's almost like a challenge people do for its own sake because it's something even Crockford failed to do correctly. Write an awesome classical inheritance pattern, write a bunch of tests to convince yourself it works, and then ignore it.
Indeed, the fact Crockford's stuff on classical inheritance in The Good Bits was wrong but the book got (and retains) so much traction indicates just how much no-one cares.
- SimHacker 13y agoCould you link to a good explanation of how that stuff fails please? Not doubting you, just want to read more.
- Tloewald 13y agoIt's been a while since I used it, and I can't remember what the problems were off the top of my head but they were face palm level. Here's a discussion on stack exchange: http://programmers.stackexchange.com/questions/173176/javascript-objects-and-crockfords-the-good-parts http://programmers.stackexchange.com/questions/173176/javasc... The general problem with all classical inheritance patterns in Javascript is that they don't really work (they treat Javascript as a static language so you get all kinds of nasty surprises because it isn't). This is particularly sad in comparison with older, conceptually simple languages like Objective-C that do this stuff properly. Crockford himself says it was a mistake to even include the section in the book (in 8 years he's never used it) http://www.crockford.com/javascript/inheritance.html http://www.crockford.com/javascript/inheritance.html The takeaway point is that doing classical inheritance in Javascript is a Bad Idea. If you think you've done it, you probably haven't. And no-one will use it.
- saraid216 13y agoThe Good Bits had way more stuff than "how to write classical inheritance". Indeed, IIRC, the section right after that was "how to write prototypical inheritance".
- Tloewald 13y agoOf course. There's lots of great stuff in Good Bits but the fact it had egregious errors in its section on classical inheritance and no-one really noticed says a good deal about how much it matters for Javascript programmers.