lua-users home
lua-l archive

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


On Monday 31 January 2011 07:33:30 steve donovan wrote:
> On Mon, Jan 31, 2011 at 2:18 PM, GrayFace <sergroj@mail.ru> wrote:
> > I'd say metatables stuff may indeed get messy, mostly because there's no
> > standard OO.
> 
> After all, it's such fun to do our own; sometimes I think this was a
> lost opportunity.  A straightforward metatable-based OOP scheme is
> maybe a hundred lines of code, which hides the 'uncomfortable' stuff
> and puts it behind a 'standard' facade.  If such a little module were
> included in the Lua 5.1 distribution (like strict.lua) then perhaps we
> would not have such fragmentation.
> 
> > I haven't heard of full OO implementations at all, by which I
> > mean support for properties, hence privates; reflection. That's the
> > number 1 candidate for standard library IMO.
> 
> Properties in the sense of getters and setters yes.  All the pieces
> are out there, but a framework that does it all could suffer in
> performance (for instance, you need a special __index to handle
> properties, which would also have to look up plain-jane methods). In
> general this is probably premature anxiety.

Speaking for myself, I don't think OOP is the be-all and end-all of 
programming. OOP's good, it's handy, but IMHO too many people try to use it 
for everything, even when the problem domain doesn't match it well. 

At more than 20 years old, OOP's starting to get pretty antiquated and may go 
the way of 60's flowcharts and 80's structured programming pretty soon. No way 
of knowing what will replace it, but it's getting pretty old.

Speaking about what might replace it -- could something with callback 
functions replace it? They're powerful as all getout, but until now appeared 
to be the sole territory of toolmakers, with application programmers simply 
writing and passing small callbacks. Could that be because in other languages, 
callbacks are just too syntactically difficult?

int binary_op(int a, int b, int (*callback)(int, int))

Really? Umm, sorry, I just don't have the time. Compare to the Lua equivalent:

function binary_op(a, b, callback)

Sweet! Understandable! Easy!

With Lua my use of callbacks has quadrupled. With C and Perl they were a 
dreaded last resort, with Lua they're a happy opportunity.

Lua having many ways to do OOP never bothered me, because Lua isn't built for 
OOP, and OOP isn't the last word in programming paradigms.

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt