lua-users home
lua-l archive

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


Javier Guerra wrote:
On Thursday 28 December 2006 12:53 am, Jimmie Houchin wrote:
Well, I basically am referencing comments about everyone rolling their
own flavor of OOP in Lua. (SWIG thread)
How important OOP is to Lua I cannot say. But for many it is their
preferred programming paradigm. And since Lua does support OOP, there is
no reason to not do it consistently and well. If I misread the roll your

for most people, OOP means encapsulation, polymorphism and inheritance.

the first two are so trivial to achieve that it's (IMNSHO) silly to try to 'standardise'. rolling your own means only think that way when coding.

inheritance is the almost-missing piece, and here is where most people find themselves doing all kinds of kludges, and/or inefficiencies.

but, at the same time, most of these schemes are interoperable, just because of using the same syntax.

myself, i've found that sometimes it's nice to think in objects, but i've never (NEVER) found myself using inheritance when not using C++. why? simple, because in dynamic languages the polymorphism is so much more flexible that it's not needed!

Now Smalltalk uses inheritance, not an option not to, and it is very dynamic. But Smalltalk has extensive and pervasive tools which encourage and enforce the Smalltalk OO paradigm. In Smalltalk it feels natural and right.

But strangely enough. When I drop out of Smalltalk into Python I tend to get very functional. I have never written a class in Python and just don't even think that way. But I have never written anything much over 1000 loc.

if two objects (i seldom use classes) are similar, just reuse the code. no need to make them fit to a hierarchy, because in a functional language you can shuffle around methods, or easily setup some delegations, or even 'aspects' if you want.

Agreed.

Personally outside of Smalltalk hierarchies can become quite challenging to understand and navigate. Smalltalk's extensive tool set enables viewing hierarchies in powerful ways. But even then you can get lost in the maze. And then if you ever need to reposition your code in the hierarchy. Ouch!

that's why i hope there's never a 'blessed' OOP scheme in Lua. just look at the mess that JS got!

No comment. I don't know what mess that is per se. But I guess I'll find out if I ever finish reading my JS book.

Having no understanding of the impact either direction of a blessed OOP in Lua. I am more than happy to let the wisdom of the Lua elders guide us. :)

Jimmie