lua-users home
lua-l archive

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


2015-12-14 18:28 GMT+02:00 Safwat Halaby <softwatt@gmx.com>:

> I have 4 different approaches for creating a classical
> OOP-style class in Lua. I'm wondering how they compare
> in terms of CPU and memory usage.

Approach 1 is the usual object-oriented approach towards
objects with the same API and implementation.
Approach 2 is "polymorphism", for objects with the same API
but different implementation.
Approach 4 is "inheritance", for objects that are small variations
of other more basic objects.

The right question to ask is: which of the above best describes
what you are trying to achieve?

I.e. how do the approaches compare in terms of program
readability and maintenance?  If CPU and memory usage are
paramount, use C.