2 ms·
Total newb question but why do games use lua, as opposed to (for instance) embedded JavaScript with some defined interface into the game (e.g. APIs to adjust ga
by bluelightning2k 2y ago
Total newb question but why do games use lua, as opposed to (for instance) embedded JavaScript with some defined interface into the game (e.g. APIs to adjust game state).
Seems to me that this would benefit from the much more severe hardening work that's gone into isolating browser environments (a hard and VERY well tested and funded target), as well as the massive work that's gone into performance optimizing dynamic types.
Plus if the mod needs UI there's the canvas and potentially even React etc if a Dom-like model is available.
- treflop 2y agoIt’s been several years since I’ve tried but most JS engines are out of date and barely maintained and the ones used for browsers are made for browsers first and they are not built for you to integrate at all. Lua is specifically built for you to integrate so there are many resources and a huge community backing you.
- bluelightning2k 2y agoThat's helpful. Thanks for the response. I think a useful caveat on that would be "...when these projects started". Roblox started in 2003 and Factorio in 2012. As of today embedding v8 doesn't seem that hard (https://v8.dev/docs/embed https://v8.dev/docs/embed)
- frabert 2y ago1. Most JS engines are vastly more complex to embed than Lua, which is one of the easiest pieces of software to compile I can think of 2. You're conflating common browser APIs with JS. A JS engine does not provide a canvas, or a DOM. V8 does not, for example: those are things you would need to add yourself.