5 ms·
People seem to say this (or similar remarks) when talking about Lua but even more specifically, LuaJIT in particular but it seems like Lua is already a pretty n
by arthurcolle 5y ago
People seem to say this (or similar remarks) when talking about Lua but even more specifically, LuaJIT in particular but it seems like Lua is already a pretty niche language so am I just missing something? Like you can embed Lua in other languages but why use Lua instead of something like mruby for all the warm fuzzy feelings you get when writing Ruby?
Just curious, appreciate any context you can provide!
- stravant 5y agoThe advantage that Lua has is that it has about the simplest possible binding interface you can imagine for a Language. There's no manifests, no class definitions, no anything really. It's as simple as calling lua_newstate to create a state, calling lua_pushcfunction to register some functions that expose your desired engine functionality, and calling lua_loadstring with a script to run. That means you can use Lua in your engine for something as simple as a CLI interface that just exposes a couple dozen functions, and it's still worth it. Where with any other scripting language you'd have to be doing a lot more with it to make the setup cost worthwhile. Having LuaJIT available if you end up wanting to do more with it later is the icing on the cake.
- pansa2 5y ago> why use Lua instead of something like mruby The main reason is momentum - Lua has been the de-facto standard embeddable language for at least 15 years. For example, it's used in World of Warcraft which was released in 2004. Another reason is the quality of the implementation - Lua has very few bugs [0], whereas Shopify tried to embed mruby and had to give up because it had too many security holes [1]. Finally, Lua is a complete language in itself, with a guidebook, reference manual and so on. Mruby (and MicroPython) are less well-known. Plenty of people know Ruby or Python, but if you use the smaller implementations, you never know when your code might hit a language feature that they don't support. [0] https://www.lua.org/bugs.html https://www.lua.org/bugs.html [1] https://brandur.org/fragments/shopify-mruby https://brandur.org/fragments/shopify-mruby
- vanderZwan 5y ago> Like you can embed Lua in other languages but why use Lua instead of something like mruby for all the warm fuzzy feelings you get when writing Ruby? I mean, we're mainly talking about games here. Choosing performance over developer comfort is the default.
- Narann 5y ago> it seems like Lua is already a pretty niche language Keep in mind that what we see on the internet is a vocal publicly part. Some important domains are not publicly represented. For example, in my domain CGI/VFX, Python is used all around, but lua has growth in some places. For example it is used in Guerilla[0] and Katana[1], two software related to rendering and scene management. Technically a niche, but commercial product too. So, groups of people uses it all day but you will not find questions about it on stack overflow. The reason to choose lua despite having Python all around is it's lightweight, apps can hack the VM for your specific needs, function call cost is faster and you can easily expand it with C (compared to Python). This is just an example related to my domain, but I suspect this pattern is similar in many domains that doesn't pop on the internet. I suspect web dev is overexposed on the internet, making people thinking it's how dev runs all around. [0]: http://guerillarender.com/ http://guerillarender.com/ [1]: https://www.foundry.com/products/katana https://www.foundry.com/products/katana