Transcript Lua
Lua By: Michael Coffman Peter Sussman History • Lua means ‘moon’ in Portuguese • First appeared in 1993 • Created by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes at Pontifical Catholic University of Rio de Janeiro in Brazil • Developed because Brazil had a strong policy against foreign trade • Primary influence: c++ Features • Light, multi-paradigm language • Highly portable: can be compiled to run on Linux, Windows, Macintosh • Very small: complete language occupies less than 1 megabyte • Dynamically typed; eight types, boolean, number, string, nil, function, userdata, thread, table • Also has automatic garbage collection Features • Only data structure is the table, which can be used to implement arrays, lists, etc. • Can run code in pure interpretation or intermediate byte code (such as Java) • Can call functions written in C or Lua • Arrays do not have to be only one type • Variables are global unless otherwise declared Code Samples Code Samples Code Samples Sample Runs Sample Runs Readability • Pros – Functions are well defined and easy to follow – Similar to C syntax – Very little parentheses or brackets • Cons – Most blocks of code end in ‘end’ – No spaces between terminals and nonterminals – Variables don’t have declared types, only their values do Writability • Pros – Few keywords – All blocks of code end with ‘end’ – Syntax similar to C • Cons – All blocks of code end with ‘end’ – Limited data types Reliability • Pros – One of the most reliable languages on the market • Cons – Easy to get lost in the nested ‘end’ statements leading to programming errors Cost • Pros – Free – Small and portable: Lua can be used from a USB drive from one machine to the next, and across multiple OS’s • Cons – Lua is not considered a mainstream language, so training might cost a fair amount Who Uses Lua • Blizzard Entertainment: World of Warcraft scripting • Cisco Systems • Maxis/EA: SimCity 4 • Adobe: Adobe Photoshop Lightroom • Many video games use Lua References • http://www.lua.org/ • http://en.wikipedia.org/wiki/Lua_(programming_language)