Reconsider adding a WebAssembly (WASM) API
#7745 was closed without real explanation why.
From webassembly.org:
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.
WebAssembly describes a memory-safe, sandboxed execution environment [...]
WebAssembly also supports non-web embeddings.
Rust+WASM vs Lua vs LuaJIT performance benchmark
WASM is already used/supported by other game engines as scripting platform.
Advantages:
- would allow people to write mods whatever language they prefer
- would improve the security situation (especially in regard to SSCSMs)
- mods could be more performant by using low-level/high-performance languages
- WASM runtimes are actively maintained, unlike LuaJIT
Lua is a beginner-friendly, fast and ergonomic scripting language. But for maintaining large code bases, having to work in a dynamically typed languages becomes a burden. I have maintained the 100KLOC MineClone2 code base and quit partly because of unexpected crashes (and the way the community dealt with them).
A look at the MineClone2 bug tracker shows that many crashes are either type errors or nil value errors. There are languages with static typing and static analysis that prevent both of these error types.
Lua might still be the best choice for most mods, especially for beginners, but I think the community agrees that Minetest also needs more high-effort games, as this is the main purpose of a game engine. WASM would provide choice.
For backwards compatibility, the Lua builtin would have to 'emulate' the parts of the Lua API that were previously provided by C++ with calls to the new WASM API.
Mods written in different languages would likely be able to only interop with mods written in the same language, unless the modder puts extra effort into providing an cross-language API for their work. Babel has been suggested in #7745 as a solution to this. In some cases, certain mods written in different languages might even be incompatible to use with each other.
ContentDB would probably have to host binary packages of mods that use compiled languages.
Source: luanti-org/luanti