Sunday, September 28, 2003
Is It High Time To Get Rid Of Classes?
Carlos Perez asks whether it's time to get rid of classes in reaction to an article written by James Coplien.
In Coplien's article he mentions prototype-based languages (also called delegation-based languages) as an alternative. Guess what? If you're doing web development you've probably already using one -- JavaScript. The NewtonScript language which was used to develop software for the Apple Newton MessagePad was also a prototype-based language. Even James Gosling, the father of Java, has mentioned that if he had it to do over again, he might design Java with a delegation model.
I have to admit that classes sometimes make me queasy. Using interfaces as the external exposed view with factories has been a successful design alternative but there's only so much you can do in a class-based language. I haven't considered how interfaces play in a prototype-based world but I believe that they fit into that model. The funny thing is that prototype-based systems can be used to construct class-based systems. People do this all of the time in JavaScript. The solution can't be to throw the baby out with the bath water -- we've got too much invested in what we've done in class-based languages. And we shouldn't just dump class-based languages because they don't always fit well. And besides, we don't have an adequate replacement yet -- although I know a developer who says that if we all just wrote everything in JavaScript we'd be a lot happier
In Coplien's article he mentions prototype-based languages (also called delegation-based languages) as an alternative. Guess what? If you're doing web development you've probably already using one -- JavaScript. The NewtonScript language which was used to develop software for the Apple Newton MessagePad was also a prototype-based language. Even James Gosling, the father of Java, has mentioned that if he had it to do over again, he might design Java with a delegation model.
I have to admit that classes sometimes make me queasy. Using interfaces as the external exposed view with factories has been a successful design alternative but there's only so much you can do in a class-based language. I haven't considered how interfaces play in a prototype-based world but I believe that they fit into that model. The funny thing is that prototype-based systems can be used to construct class-based systems. People do this all of the time in JavaScript. The solution can't be to throw the baby out with the bath water -- we've got too much invested in what we've done in class-based languages. And we shouldn't just dump class-based languages because they don't always fit well. And besides, we don't have an adequate replacement yet -- although I know a developer who says that if we all just wrote everything in JavaScript we'd be a lot happier
RSS 0.92 Feed