3 ms·
Yes. You can compile Lua code with `loadstring("return 1 + 1")`, which returns a function that runs the provided code. `loadfile()` does the same thing with fil
by nonbirithm 5y ago
Yes. You can compile Lua code with `loadstring("return 1 + 1")`, which returns a function that runs the provided code. `loadfile()` does the same thing with files. You can also change how the import mechanism works to load compile-to-Lua languages or similar. There are also first class functions and functional programming libraries. I'm personally a fan of luafun.
Usually when programming Lua I can remember every detail of the language without having to consult a reference or wonder which library does what, because it's so simple. I understand that too much simplicity might be an issue for other people, though. I sometimes wish that JavaScript was as simple and easy to understand as Lua is, and Lua is also free of many of JavaScript's warts, but the lack of proper OOP support seemed to kill adoption of the language in projects like Torch. It's still possible to use Lua's prototype-based paradigms to implement OOP, but the implementation details vary depending on which OOP library you choose, and the lack of first-class support is unsatisfying for many people. For me it was more of a mindset thing, and I found I was happier settling for a limited version of OOP or eschewing it for prototype-based programming instead, as it was simpler and satisfied all my needs.