Better inheritance for Prototype

Justin Palmer, author of the Pragmatic Programmers’ upcoming book on Prototype, writes about the madness of Prototype’s current inheritance scheme.

Thanks for bringing this up Justin. Prototype’s class system is definitely experiencing growing pains. We’re very fortunate to have developers smarter than I am attempting to clean things up.

One such attempt can be found in ticket #4060, which offers an all-encompassing, Java-esque class system that’s entirely backwards-compatible with Prototype’s current system.

I’ve been reluctant to apply this patch because it’s heavy in terms of code size and conceptual overhead. Prototype provides simple solutions for 80% of people’s page scripting problems, not baroque solutions for the remaining 20%. We need to find a simple answer to the problem of inheritance.

Justin suggests Dean EdwardsBase, which solves six problems with OO programming in JavaScript. I like Base because it’s simple, clear, and born from someone who’s felt the pain of writing real JavaScript applications.

I don’t have a roadmap for Prototype, but version 2.0—the next major release after 1.5—will focus on polishing what we have now, not on adding new functionality. You can expect Base to make its way into Prototype 2.0 in a form that’s backwards-compatible with Class.create and Object.extend.

— May 23, 2006