I recently made the perfect one which can be found here - https://github.com/be-thomas/createClass
Why it is perfect?
See the features -
1) simple usage & implementation
2) small (one file, just 140 lines)
3) support for static and instance properties
4) easy inline getters/setters
5) support for `super`
6) support for printing classes & objects with proper indentation
Yep, you can print classes too, the and it preserves indentation(even nested indentations).
Example :-
Code: Select all
class {
set: function: 0x010085a628,
super: class {
constructor: function: 0x0100864db0,
set: function: 0x010085a628,
_: table: 0x0100864c10,
},
constructor: function: 0x0100867298,
_: table: 0x0100867040,
}
object {
set: function: 0x010085a628,
super: table: 0x0100867348,
constructor: function: 0x0100867298,
_: table: 0x01008674e0,
}
Why to use this instead of other heavy libraries?
We are bound to have a lot of objects & classes in our games. It is always a good idea to reduce the complexity and memory usage.
Even the code of those OOP libraries are pretty complex taking up a lot of resources.
Some say OOP in 100 lines but when you see the code, it is actually supposed to be of 400-500 lines but shortened through some obfuscator!
Credits: Forked & improved from https://github.com/jonstoler/class.lua