Hello World in Lua

Lua is a powerful, fast, lightweight, embeddable scripting language. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.


Download the current Lua version 5.1.4 by typing:

~# wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
~# tar xvzf lua-5.1.4.tar.gz 

Probably you need to install make to compile the Lua sources by typing:

~# apt-get update
~# apt-get install make

Change into the Lua directory by typing:

~# cd lua-5.1.4 

and install the package by typing:

~/lua-5.1.4# make posix
~/lua-5.1.4# make install

The Hello World example is stored in test/hello.lua directory:

io.write("Hello world, from ",_VERSION,"!\n")

To launch it type:

~/lua-5.1.4# src/lua test/hello.lua
Hello world, from Lua 5.1!                                                      

Related links


Thanks to Claus Kuehnel (www.ckuehnel.ch) and Daniel Zwirner for the contents of this article.