Saturday, June 27, 2009

Adventures in Lua (I)

After studying and working with Lua for about a year now, I find it to be a very powerful and innovative language. While the syntax is not my favorite, overall it's fun to work with. Recently I started using the standalone lua interpreter for some general purpose scripting which has revealed to me a few key reasons that Lua (the language) or at least lua (the interpreter) won't be readily employed for system scripting on a large scale anytime soon.

  • GetOpts - Doesn't exist. Which isn't really a big deal for me.. sure the (korn) shell has it but plenty of other scripting languages don't have it (like AWK)

  • DELIMITERS - in the LUA_PATH environment variable the delimiters are semicolons(;) as opposed to the colons(:) used in most posix apps.

  • RegEx - Lua doesn't have the Posix Regular Expressions Engine nor GNU's or Perls. There are some very innovative constructs for complex (and simple) pattern matching and an equivilent to back references called yank but it's going to take you some time to get used to if you're accustom to regular Unix REs.

  • ARGV[] & ARGC - They don't exist... well not as you might expect them to anyway. There is an arg or args table created with the values passed to the script as command line arguments, however I was told that args is deprecated or will be shortly.

  • COMMENTS - Okay this one is really a minor issue. If you're used to SQL comments as opposed to those in the shell, AWK, Perl, bc, etc.. then you're in good shape. In Lua Comments begin with a double hyphen or dash (--)


As I said before, I really enjoy working with Lua. The systems engineer/hacker in me wants to find as many ways to utilize it as possible. (Yes, I'm crazy like that.) We'll see if I've reached any new conclusions after I've done more applications programming with lua.

No comments:

Post a Comment