I hate Lua with a passion almost equal to how I hate Java.

by debianjoe

local local local local = print


Lua is a fantastically easy to learn scripting language that is easily embedded into other languages via C/C++ bindings and is under a BSD style license.

Now that we have that out of the way, let’s talk about my intense loathing for Lua.  It has no strict syntax, only parsing of code.  This in one of the major advantages of Python, because a scripting language should make sense to anyone who knows how the language works.  Lua throws the “one right way” out the window for a much more “however you feel like doing it” approach.  Since it is often one of the scripting languages that people will learn early on in their programming careers, it almost breeds bad practices.

Add this to the fact that it defaults everything to a global scope and thus you’ve got a few really interesting options.  Use global scope for everything (a horrible idea, as it’s slow and creates serious debugging issues), or you can simply do like most Lua programmers and explicitly type “local” every time you wish to use a variable locally.  This leads to great complications when dealing with lower level languages, where most variables should be processed locally and then passed by value.  Functions in Python cover a much more standard way to handle the passing of global and localized variables.  As each is a scripting language, this isn’t a big issue…but one leads to a far more reasonable understanding of lower level languages.  By standardizing practices, learning new languages becomes far easier.  Also, polluting global namespace is disgusting.

Lua arrays often begin at ‘1’, which makes no sense to anyone that has ever studied even the least bit of computer science.  I realize that this is not necessary, and that it is due to the programmer having the freedom to start the index wherever they wish, but let’s not get in the habit of pretending that 1 is the first number that we count from in computing.  Nulls are hard enough to explain to people coming from a scripting language to a medium-level language without having to remind them that 0x00000000 is a valid memory address, and that we start counting with 0.  

The biggest thing that I hear in defense of Lua is that it’s “high performance” as long as you don’t allow it to write to the global namespace and actually handle the locals correctly.  While this is true, it’s still a scripting language.  It’s not as fast as a decent compiled language, and it lacks the power and flexibility of either Python or Lisp.  I have yet to determine the need for so many different ways to skin a cat, and one that promotes bad coding while being marginally used at best is certainly not the way to win me over as a fan.