3 ms·
I think any object/type system is good, as long as it doesn't encourage atrocities. I personally am guilty of implementing a fully-blown class-based inheritance
by rollcat 3y ago
I think any object/type system is good, as long as it doesn't encourage atrocities. I personally am guilty of implementing a fully-blown class-based inheritance system on top of Lua's metatables, and thank $DEITIES it didn't make it into any production project!
Nowadays if I write Lua, I mostly see metatables as a memory usage optimization. If you have thousands of small objects with many methods, and all of them share the same set of methods, it makes a lot of sense to have a single vtable, to save some memory. Otherwise I wouldn't bother, it's not like Lua lets you control struct member padding to ensure they fit in a single cache line.