3 ms·
There's some things intrinsic to Lua's design that makes it better for performance & embedding. Take a look at how LuaJIT destroys JS in most benchmarks. Lua a
by vvanders 10y ago
There's some things intrinsic to Lua's design that makes it better for performance & embedding. Take a look at how LuaJIT destroys JS in most benchmarks.
Lua also has coroutines and a few other things that don't exist in JS. JS certainly has the market share and libraries but there's quite a few areas where Lua does much better.
- lifthrasiir 10y agoI'm pretty sure that the original designers of Lua didn't envison that, but LuaJIT is quite nice. I like Lua coroutines but I think JS has practically caught up with generators and other external supports.
- vvanders 10y agoHuh, didn't know about generators, learn something new every day(although like everything with JS support looks a bit spotty).
- pygy_ 10y agoGenerators are also less general. You can't `yield` from a non-generator function. In Lua, coroutines are implemented as a library, not as a core language/syntax thing.
- vvanders 10y agoPretty sure coroutines are a core part of the language since there's specific C APIs around them but I could be wrong.
- pygy_ 10y agoThe library requires low level access to the VM, but you can yield from anywhere, and pass `coroutine.yield` as a value to higher order functions. However, there are (were?) restrictions when C functions are present on the call stack between `coroutine.resume` and coroutine.yield`. Edit: not that low level, actually, here's the coroutine implementation, built on top of the public Lua C API: http://www.lua.org/source/5.3/lcorolib.c.html http://www.lua.org/source/5.3/lcorolib.c.html (167 lines including white space and comments).