Noop language

Nick Sabalausky a at a.a
Tue Sep 22 22:13:15 PDT 2009


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:h8t7e8$1fa7$1 at digitalmars.com...
> Google labs are thinking about another language that runs on the JavaVM, 
> named Noop, "A testable programming language":
> http://code.google.com/p/noop/
>
> It has no subclassing, no primitives, and by default variables 
> (references) are final & not null. It uses properties by default.
>

You know, when I first read this post, my thought was "Great, yet another 
'purity' language that tries to cram ideology and VM down my throat." But 
there's one thing that, nearly a week later, I just can't get out of my 
head:

> Proposal For Composition. Perhaps inheritance can be completely replaced 
> by composition plus polymorphism:

I've been giving occasional thought for a while now to both polymorphism and 
class-extending (Although usually more in terms of C#-ish extension methods 
rather than composition). I admit I initially knee-jerked at the idea of 
getting rid of inheritance; it's certainly very useful in many cases.

But the more I think about it, the more I can't help wondering if it's a 
mistake to make inheritance a primitive, since it's really a marriage of two 
things: polymorphism and adding new stuff to a class after-the-fact. 
Granted, strictly speaking, you *can* use only the polymorphic aspect of 
inheritance (don't add any new members), or only the class extending aspect 
(don't override anything). But there are still a bunch of ugly corners that 
have arisen from inheritance being the primitive for polymorphism, and from 
inheritance/composition being the primitives for extending:

- Multiple dispatch isn't supported without a clumsy workaround like the 
visitor pattern.
- Extending via inheritance is problematic when the public interface is 
self-referential (ex: If you subclass a "BasicTreeNode" to add "display" or 
"find", what do you do with "get child" and "get parent"?).
- Extending via composition involves a lot a boilerplate and maintenance, 
both of which are usually only solvable with more clumsiness.

So I have been thinking that maybe polymorphism and extending should be 
primitives in their own right, and maybe inheritance could be built out of 
those (or left in as a helpful tool for porting and for when inheritance 
really is what's needed). Looks like I'm not the only one to think this ;)





More information about the Digitalmars-d mailing list