Friday 3 May 2013

Lua – The Rising Star

While there are many scripting languages today including but not limited to Perl, Python, Ruby, etc., a scripting language that has gained lots of popularity in a very short time is Lua. It came as tiny and lightweight programming language especially targeted at games configuration language. It gained popularity especially through World of Warcraft game.

lua

Lua is simple, has a negligible memory footprint and a very easy syntax that even n00bs can master (~cough~gamer kids~cough~). It is a scripting language that is run by the Lua interpreter. The interpreter is very tiny and has almost all the basic features a modern scripting language should have. The language itself was created in such a way that it is very easy to embed into a C program. In fact, when people require a scriptable, light and versatile language the first thing they prefer is Lua.

Let’s talk about its syntax-

  • Lua loosely-typed language and variables can be used without any previous declaration. However, there is a local keyword that makes a variable limited to its current scope, that is if inside a function then only limited to that function. local also “defines” a variable in a way (in a very unobvious and unexpected way LOL).
  • Lua has “quantitative” (I could not find another word for it) data types that is variables and tables (acts both as list and dictionary data types). The data types are automatically adjusted in the program.
  • There are no braces in Lua and blocks are determined by do..end keywords. There is also no mandatory 4-spaces-before-indented-line thing in it like Python. Simple code statements can be written as one liners.
  • Functions can omit open and closing brackets like in Perl when giving in parameters. Also, statements are not followed by semi-colons as in C/C++ or Perl and are terminated by a newline.
  • Lua single line comments are like in SQL, just two dashes (--). However, multiline comments are much frowned upon by people since they are like (--[[ any comment here ]]--), that is we have to use 8 characters to make a multiline comment! God knows who gave this brilliant idea.
  • The syntax looks like BASIC or Python but somewhat better than BASIC and more free than Python.

Lua has been taken by many people as a “n00b script” by many. But this is not the truth because it is faster than both Perl and Python. It might not have so many modules in its library like Perl or Python but it is growing. It looks very promising and we should give it some time to get stuff added to it. After all it takes some time for moon to rise in the sky before it gives light to a dark land.

0 comments:

Post a Comment

All Articles © Asit. No Copying. Powered by Blogger.
 
Copyright © . The Tech Veda - Posts · Comments
Markup Powered by Bluefish Editor 2.2