2 ms·
> In all, I think the Lua's require is a much cleaner way to implement modules. The idea behind ES6 modules is to add static name resolution to JavaScript. Bec
by pcwalton 12y ago
> In all, I think the Lua's require is a much cleaner way to implement modules.
The idea behind ES6 modules is to add static name resolution to JavaScript. Because of the incredibly dynamic nature of JS, you can never know what any global name resolves to, as it could change at a moment's notice. The same is true in Lua's module system: `_G` is completely mutable and it (or its metatable!) can change at any time, altering the bindings in the program.
I personally feel that, given how JavaScript is getting used in larger and larger codebases, some measure of static checking was long overdue.