lua-users home
lua-l archive

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


Quick feedback on my experience. I'm originally a C++ programmer, and
I enjoyed using all advanced concepts that templates provides. When I
switched to Lua, I first tried to find an OO system, and then tried to
do my own (but I used class keyword :-) ). Finally I even wondered how
to modify Lua parser to add a class concept (even as a syntactic sugar
would have been ok).

But during that time I learned Lua, and its advanced concept. I read
as many advanced tricks as I could and I've discovered how flexible
Lua is. And finally I felt no need for a complex OO system. I keep an
OO approach only for data that fit that paradigm well, but with the
simplest system possible : the metamethod mechanism and the
"obj:func()" syntactic sugar.

After all OO frameworks exist to save your time, by factoring all code
that can be reused. Encapsulation and most other OO concepts help to
keep the whole thing clean and easy to use. On the other hand, in Lua
everything is straightforward to do with language mechanism. With a
few lines of closures and coroutines you can write complex mechanisms
that would have taken thousands of C++ code to emulate. So the help
that OO provide in low level language like C/C++ become a burden in
high level languages like Lua.

And for your license concerns, using plain Lua as-is with its basic OO
syntactic sugars costs nothing more than Lua itself :-)

2006/10/12, Zed A. Shaw <zedshaw@zedshaw.com>:
On Thu, 12 Oct 2006 10:10:24 -0600
"Gavin Kistner" <gavin.kistner@anark.com> wrote:

> From: Zed A. Shaw
> > 1) What's people's favored OO system for Lua and the
> > advantages/disadvantages?
>
> I wrote my own OO system that mimics (but doesn't match) the basics of
> Ruby's inheritance hierarchy.
> http://phrogz.net/AnarkSamples/AKClassHierarchy.lua
>

Looks good.  What's the license on it though.  Seems people do three things in Lua:

1) Write their own OO system.
2) Avoid the words "[Cc]lass", "[Oo]bject", and "new"
3) Not put a license on it.

Are there particular reasons for this?  Like, "class" is reserved or clashes?

--
Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://www.zedshaw.com/
http://mongrel.rubyforge.org/
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.