- Programming in Lua – class notes.
- Terra – low level lua like language.
- Lua - good, bad and ugly parts
- Lua 5.1.4 Annotated Source
Links and references
- Lua.Space – lua community blog; started Dec 2015.
- What’s different about Lua
- Is Lua interesting, from a programming language design perspective?
- Lua date manipulation
- Lua - world’s most infuriating language.
- How to lua and c - a short novel
Cool lua stuff
- Performance counter access with inline assembler in Lua
Luvi A project in-between luv and luvit. The goal of this is to make building luvit and derivatives much easier. Luvi has a somewhat unique, but very easy workflow for creating self-contained binaries on systems that don’t have a compiler:
- The Fennel programming language . note.
- bakpakin/moonmint: A Web Framework for Lua
- Urn: A Lisp implementation for Lua | Urn
- rxi/lume: Lua functions geared towards gamedev – “lua’s missing standard library” according to \@technomancy
- Calvin Rose – bakpakin.com (creator of Fennel lang, moonmint web framework, etc.,)
Compiling Lua source files
Let’s say you have a lua program –
The source code can be compiled into a binary file using
$ luac -o hello.luac hello.lua
The file hello.luac can then be used in place of the source file. Using the binary file has some advantages like: faster loading, simple source hiding etc.,
To run a
.luac file (this is my own convention, the Lua docs do not
seem to prefer any particular suffix for the compiled file), you still
need to call the lua interpreter,
$ lua hello.luac
Creating standalone executables for lua
A Lua source file can be converted into a executable using different
srlua appears to be the popular one.
here and build it using
srlua files into a convenient location, say
You can now create standalone executable from the Lua source file
$ ~/bin/glue ~/bin/srlua hello.lua hello $ chmod +x hello $ ./hello Hello Lua!
Installing new software packages
Luarocks is the deployment and package management system for Lua. Think CPAN for Perl and PyPI for Python.
I have installed Lua in my
$HOME directory. That is,
$HOME/bin, include files in
So, to install Luarocks:
$ export PREFIX=$HOME $ ./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config
Installing new lua packages is as simple as:
$ cd luarocks install luasocket
luasocket is a new package that
is fetched from the luarocks mirrors and installed.
To make this package available to the Lua interpreter export
Also, to explicitly add paths to a script:
# cat t_paths.lua package.path = package.path.. ";/opt/local/share/lua/5.1/?.lua" package.cpath = package.cpath.. ";/opt/local/lib/lua/5.1/?.so" local s = require "socket" print(s._VERSION)
Incidentally, on the day I was learning aobut
the main lua modules repository was down. Friendly folks on the
IRC channel told me to add mirrors to the luarocks configuration.
$ vim ~/luarocks/config.lua
I replaced the luaforge.net line with
LUA_CPATH is always more complicated than it
needs to be. Remember not to have any spaces after the path seperator
LuaDist appears promising to set up
like sandboxed environments (and more..) for lua.