>>9193Fellow gamedev. Lua is great. However creating bindings for it is a pain.
IMO, it's best used as an embedded language where most of your program is native C/C++, etc. and you make these powerful things user scriptable in Lua. That lets levels / mods have new logic without requiring adding code to the engine. This is also what some machine learning systems do. Lua could be swapped out with Javascript, Lisp, or Perl and it wouldn't matter there: It's not like Lua is doing the heavy AI work, it's just being used as an embedded glue language (like Javascript was designed to be).
Even with Lua JIT it's not yet great for doing the heavy lifting on its own.
My problem is that if I make my codebase modular enough to embed Lua e.g. call a function pointer from the mainloop for per level logic: level.tick( elapsed ), then just have a level_XX.c file for each level (which adds an entry to linked list of such level structures), then I get the same sort of per-level customization, and efficient compiled code, for a LOT less coding time than creating Lua bindings, albeit without runtime scripting Lua grants. There is something to be said for debugging projects in a single language vs two languages and a binding shim.
Lua is very worth learning if you really need an embedded runtime scripting system. However, I'd argue that Javascript would be more familiar for end users. In my past projects I just implemented a simple MIPS virtual machine (it's really not hard). Then you can have runtime "mods" written in C/C++, Lua, Lisp, FORTH, Fortran, basically any existing language there is with a compiler for MIPS. Just provide the header files to compile against -- these take the place of in-source "binding" glue for Lua.
I think Lua is a pretty good stopgap, but still just a stopgap. What we really need is an Algo-like (C-ish) compilable language that is also its own scripting language. I once began implementing a runtime compiler for C, but the standards are so damn boated it's ridiculous to use it as a scripting language without making it incompatible with the standard's syntax.
Lua (and other glue-langs) shine now because we don't have a good compilable language that you can also just take it's compilable code and run it as a script at runtime -- or take a piece of runtime script that you've been working on and speed it up by marking it as compilable pre-release.
Perhaps Lua could be extended to a general purpose compilable language and provide transparent script-ability, but it suffers in this regard for the same reason Lisp's design does: Neither was designed to do the task we really want (hybrid compiled/scripting language). Lisp already exists and can be somewhat compiled + scriptable, but it wasn't really designed to play well with the realities of underlying architectures and (despite the beauty of it's logic) it was designed to be dynamic (also the the syntax is like kicking dead whales down the beach)
))))))))))))))))
Lua, and other hybrid "embed a VM in your C" solutions are answers to the problem that only exists because modern compilable languages don't have simple to compile syntax and provide a hook to invoke the compiler at runtime. We are going that way though. In other words: Interpreted languages already dissolve the difference between "runtime" and "compile time", compilable languages will eventually dissolve the distinction too. Until then Lua is a great stopgap solution to the runtime inadequacies of modern compilable langs.