lua-users home
lua-l archive

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

On Tue, Feb 14, 2012 at 10:39 AM, Sean Conner <> wrote:
> ...  Also, I'm not a big proponent of object
> oriented programming, and I find what Lua provides just fine for my own
> needs (I stay as far away from C++ as possible), so I don't quite understand
> this whole obsession over objects.

Well, twenty years of OOP has ingrained a way of thinking about
problems and enshrined it as the Way.  It's still a fine way to
organize solutions to some common problems.  It would obviously be bad
if the language enforced it, but (fortunately) that's not going to
happen.  [0]

Newcomers would be more comfortable if there was a straightforward
pre-packaged way of making classes; the trouble comes when they see
something like LOOP and run screaming to the comforts of their
favourite OOP scripting language.  Experienced developers have another
problem, which is that they cannot share more than the assurance that
duck:quack() works.[1]  (We can't even assume that getmetatable(duck)
represents a Duck 'class' and that's a feature, not a bug [2])

So (like Jay) says: keep it really simple.  Encourage newcomers to use
a little library if they feel the urge to make class hierarchies, even
if it just contains the mt.__index = mt incantation.

steve d.

[0] This powerful urge results in derivative languages which provide
the much-needed class sugar: CoffieScript for JavaScript, and now
MoonScript for Lua.
[1] Some people enjoy saying duck.quack(), and Lua can satisfy them,
at the cost of confusing everyone else and creating an unbounded
number of closures.
[2] Similar cognitive dissonance happens with people new to Go, which
basically does compile-time duck typing.