Science Fair Projects Ideas - Lua

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Lua programming language

This article is about the Lua Programming Language. For other usages, see Lua.

The Lua (pronouced LOO-ah, or in IPA) programming language is a lightweight imperative and procedural language, designed as a scripting language with extensible semantics as a primary goal. The name is derived from the Portuguese word for moon.

Contents

History

Lua was created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo , and Waldemar Celes , members of the Computer Graphics Technology Group at the Pontifical University of Rio de Janeiro in Brazil. Versions of Lua prior to version 5.0 were released under a license similar to the BSD license. From version 5.0 onwards, Lua has been licensed under the MIT License.

Lua has been used in many commercial applications (e.g., in LucasArts' Escape from Monkey Island adventure game and robot control software) as well as non-commercial applications (like Angband and its variants). Some of its closest relatives include Icon for its design and Python for its ease of use by non-programmers.

Features

Lua is intended for use as an extension or scripting language, and is compact enough to fit on a variety of host platforms. It supports only a small number of atomic data structures such as boolean values, numbers (double-precision floating point by default), and strings. Typical data structures such as arrays, sets, hash tables, lists, and records can be represented using Lua's single native data structure, the table, which is essentially a heterogeneous map. Namespaces and objects can also be created using tables. By including only a minimum of data types, Lua attempts to strike a balance between power and size.

Lua's semantics can be extended and modified by redefining certain built-in funtions in metatables. Furthermore, Lua supports advanced features such as higher-order functions and garbage collection. By combining many of its features, it is possible to write object-oriented programs in Lua.

Example code

The classic hello world program can be written as such:

print "Hello, world!"

The factorial is an example of a recursive function:

function factorial(n)
    if n == 0 then
        return 1
    end
    
    return n * fact(n - 1)
end

Internals

Lua program isn't interpreted directly, but compiled to bytecode which runs on Lua virtual machine. The compilation process is typically transparent to user and performed during run-time, but it can be done offline, in order to increase performance or to reduce memory footprint of host environment by leaving out interpretor part of Lua.

This example is the bytecode listing of factorial funcition described above (in Lua 5.0):

function <factorial.lua:1> (10 instructions, 40 bytes at 00326DA0)
1 param, 3 stacks, 0 upvalues, 1 local, 3 constants, 0 functions
    1   [2] EQ          0 0 250 ; compare value to 0
    2   [2] JMP         0 2     ; to line 5
    3   [3] LOADK       1 1     ; 1
    4   [3] RETURN      1 2 0
    5   [6] GETGLOBAL   1 2     ; fact
    6   [6] SUB         2 0 251 ; - 1
    7   [6] CALL        1 2 2
    8   [6] MUL         1 0 1
    9   [6] RETURN      1 2 0
    10  [7] RETURN      0 1 0

Applications

Lua features prominently in many games, such as World of Warcraft, a massively multiplayer online role-playing game, where users are able to customize its user interface, character animation and world appearance via Lua, and Bioware's Neverwinter Nights PC role-playing game, where it is used as a module scripting language. It also appears in some open-source games such as the roguelikes ToME and H-World .

Therescript , used to drive the vehicles and animations in There, is a slightly modified version of Lua.

The window manager Ion uses Lua for customization and extensibility.

External links

10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice