3 ms·
Lua is a language that is designed to be embedded, which is rare in this world, thus it lacks the arrogance that it has to do everything. This allows Lua to foc
by dottrap 12y ago
Lua is a language that is designed to be embedded, which is rare in this world, thus it lacks the arrogance that it has to do everything. This allows Lua to focus on specific things so it can excel in those areas like the scripting domain, and knows you can and should do the low level things in the host language (e.g. C).
Lua is small, lightweight, fast, and elegant. It is one of the few languages that tries to remove features instead of add them. It likes to give you mechanisms to build more powerful features (like metamethods), instead of making the language bigger and more complicated and redundant. These mechanisms feed back into the notion that it is a terrific language for embedding, to allow you to make a Domain Specific Language for your specific needs.
Because the language is so small and clean, it is also the reason it is fast. Then something brilliant like LuaJIT gets created, and can realize the dream of outperforming optimized C code.
Also because the language is small and clean, it is a much easier language to secure and use in secure environments. Wikipedia uses it now for their multimedia scripting engine because it was small, fast, and easy to audit for security. Lua is also sandboxed/secure by default. It was also easy to modify for their specific needs (like embedding in PHP). And Verisign uses it for their high reliability transaction servers because they had the bold idea of using a foundation that was auditable for reliability instead of spending lots of money to build redundancy expecting the platform to constantly crash.
Lua's original popularity was in embedded devices because it is so small, it is one of the few languages you can get on a embedded device. It is also written in 100% clean/ANSI C (no platform #ifdefs needed) so it ports everywhere there is a C compiler (which is everywhere).
Lua caught on in video game development in the late 90s and became the dominant game scripting language in the industry. It is a great language to embed and interoperate with the C/C++ engines. The high performance stuff would still be done in C/C++, but the higher level content could now be done by artists as Lua is one of the cleanest and simplest languages to learn. And on the performance front, another thought exercise told to me recently was that Lua is about 100KB; that means it can now fit entirely within a modern desktop CPU's L2 cache which is a huge performance advantage.
If you want a kitchen sink language that has every library included from the start, there are languages better suited for that than Lua. But if you have specific needs like being embedded in a native app, or small footprints (memory constrained, CPU limited), and specific libraries you want to bind, or want security and sandboxing, Lua shines above all in this domain.