2 ms·
You can create elaborate class systems using metatables in Lua; the problem is that there are hundreds of them. I've done some Lua programming using Love2D, and
by lasagnaphil 8y ago
You can create elaborate class systems using metatables in Lua; the problem is that there are hundreds of them. I've done some Lua programming using Love2D, and one of the painful parts was that a lot of the major libraries implemented different class systems (or rolled one of their own), making it hard to include in a single codebase. (At least Lisp has CLOS as its common class system...) Also you can mitigate the "undeclared variable = nil" problem using a script like strict.lua (https://github.com/deepmind/strict/blob/master/strict.lua https://github.com/deepmind/strict/blob/master/strict.lua), but when you try to expand that for field accesses you then want to make sure all of those libraries with different class systems or methodologies are also compatible with it (which a lot of the libraries do not).
The underlying problem with Lua is that it went too wild with the philosophy of "being the most expressive using the least amount of features" (so you can implement everything using only metatables). Although many would say that this is a good thing, for me it seems better for a language to have some kind of subset for which people can conform and rely on.
- mmjaa 8y ago>You can create elaborate class systems using metatables in Lua; the problem is that there are hundreds of them. I have done quite a few Lua projects, and I can tell you've not quite gotten it right. The Class system you use is the one you take with you on the project. This is a strength, not a weakness; your patterns are a base file in the project.
- TooBrokeToBeg 8y agoThis has been my experience.
- samatman 8y agoLua provides only a meta-object protocol, without blessing a single class system. I prefer this. Its more Scheme-like, philosophically. I've seen your criticism from many quarters and here's my guess at what happens: people come to Lua from other languages, find missing abstractions, recreate them, and in the process don't thoroughly learn the metamethod system. Pure prototyping is a joy once you realize what all the moving parts are and how many ways they can be usefully combined. This is my experience anyway.
- int_19h 8y ago> the problem is that there are hundreds of them It is a problem when writing general-purpose code in Lua. But why would it be a problem when deciding to embed it, and comparing it to Gravity in this context? With Lua, you'd pick one such system, and stick to it. With Gravity, the system is picked for you - if you don't like it, too bad.