User Tools

Site Tools


programming:lua

This is an old revision of the document!


Lua Programming Language

Lua is a scripting language that is commonly embedded within other applications. It is very portable. You can learn to program Lua with the free ebook on the official website, Programming in Lua, 1st Edition.

Installing

In Debian you can simply use the package manager:

sudo apt install lua5.3

Also search for other packages with apt-cache search lua because there are a lot of libraries available like http, json, filesystem, curl, curses, databases and more.

If you want to build from source, it's very easy because it's so portable and written in ANSI C. Simply [[https://www.lua.org/download.html|download], extract and run make.

wget http://www.lua.org/ftp/lua-5.4.3.tar.gz
tar zxf lua-5.4.3.tar.gz
cd lua-5.4.3
make  # sudo apt install build-essential
src/lua -v
src/luac -v
sudo make install  # Optional

Hello World

There are a few ways you could execute the Hello World code.

- In the interactive REPL: lua - By invoking the Lua interpreter and passing it a file: lua hello.lua - By executing a script directly with a shebang (#!/usr/bin/lua): ./hello - Running a precompiled script (luac hello.lua): lua luac.out

hello_world.lua
print 'hello world'
programming/lua.1617345752.txt.gz · Last modified: 2021/04/02 06:42 by nanodano