lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Martin Doering wrote:

> So I'm glad, that inheritance in Lua is just an option.
> For most scripts I would write I would not need this. And
> it would make the language itself more complex if totally
> integrated in it, like in e.g. Python.

I don't agree with your last statement about Python (I don't see Python as
being a terribly complex language).  What makes Python complex is the class
libraries.  Complexity at the language level is more appropriate for
"kitchen sink" languages like Perl or "over-design by committee" languages
like C++.  But regardless, I liked the John Ousterhout quote.  Most
everything he writes seems like a tiresome advertisement for TCL, but he's
right when it comes to inheritance.  I know (and work with!) many
programmers who use inheritance to excess, introducing all sorts of

Lua might be called an "object agnostic" language.  It doesn't force the
programmer into using objects, but if the programmer does want to use
objects, they can choose their object paradigm.  Lua doesn't mandate the
use of classes to model objects.  If you're more the kind of person who
likes prototype-based objects (as in Self and JavaScript) instead of
classes, you're free to implement that.  If you were feeling ambitious, you
might even get meta and go for a pattern-based object (like in BETA).  Or
you can mix and match the best features of any of these, using whatever
makes sense.

For example, I'm not a big fan of implementation inheritance, but I use
data inheritance often.  So I can create objects in Lua that only inherit
data, not code.

That's what separates Lua from a lot of languages-- it provides the hooks
one would need to extend the semantics of the language.  Only a handful of
languages give you that level of control (such as Lisp and Forth).