Lua
2009-04-22
Looked a bit at Lua lately, as tinypy doesn't really seem to carry on (yet) and so is a bit risky to use for anything.
Good points about Lua I've seen at first glance:
- Human readable syntax.
- Simple, fast and small virtual machine.
- Secure embedded execution.
- Easy to embed and extend in a C program.
Bad points:
- Syntax is almost too simple - it's almost 100% identical to a 20 year old BASIC dialect.
- Variables are global instead of local by default - catastrophic design mistake.
- Arrays start with "1" instead of "0". Somewhat cumbersome.
The global variables are a kinda big issue, makes it very hard to use scripts in a good way if you have many of them. But of course nothing stops you from sticking a "local" before every use of a variable - which would negates the "human readable" part in the good points though. Oh well.
Update
I figured out a rather easy way around the global variables problem. The answer is
lua_setfenv. Basically it means in C code I set a new environment for each Lua module. Then the Lua code can use global variables but they are only global to this module. Variables in other modules can be accessed simply by preceding them with the module object. So, this is quite nice.