Learning Some Lua
07 August 2013
Dec 2012 I got into
lua for some multiplatform (android/iOS) programming with
MOAI. I was making a flood-it like game called
Gopher's Birthday. Though I abandoned the project for the time being, this was my experience with Lua.
Lua did quite a few great things:
- Amazingly small and minimalistic in an almost criminal fashion. This is part of what makes it so embeddable. Some of the "trivial" missing things:
- No default recursive "tostring" for tables (kinda like dicts in python)
- No default recursive comparison of tables ({"a":3} != {"a":3})
- No default inheritance mechanism, roll out your own!
- No sets, no heaps, nothing, just tables.
- Very fast, LuaJIT was pretty dominant on The Computer Language Benchmarks Game before the game removed alternative implementations.
- Metatables are a very smart solution for an oh-so complex problem. You can have all the fun of a fully dynamic language and keep the bare bones clean and simple for JIT optimizers.
But aside the great things this language has, there are quite a few nefarious warts.
I wrote this rant 8 months ago so I hope I haven't presented anything wrong or outdated.
In general, lua won't stop you from coding like an idiot. Errors pass silently in many unexpected places. But it is a small, wonderful, and useful little language.