The aim of this project is to offer a complete framework for numerical computing based on LuaJIT which combines the ease of use of scripting languages (Matlab, R, ...) with the high performance of compiled languages (C/C++, Fortran, ...).
Consider the following introductory example:
The numerical simulation is executed entirely in LuaJIT more efficiently than a corresponding C implementation (see below). The simple interfacing with R and its libraries is exploited to produce the plots:
About Lua, LuaJIT, SciLua
Lua is a dynamic language characterized by a small number of simple but powerful concepts that allow to easily implement complex algorithms. Lua is fast to learn thanks to its high-level nature, to the concise syntax and to the precise documentation. Lua is a proven robust language that has been used in many industrial applications (from Adobe Lightroom to World Of Warcraft) and offers object-oriented and functional programming features. For a more complete overview see www.lua.org.
LuaJIT is an extremely optimized Just In Time compiler for Lua. It's widely considered to be one of the fastest dynamic language implementations and the typical performance of idiomatic LuaJIT programs is close to C/C++. For instance the numerical simulation performed above by LuaJIT is faster than a corresponding C implementation which leverages on the GSL library (see Darren Wilkinson's MCMC experiment for such an implementation). For the documentation and for more performance measurements see www.luajit.org.
These reasons make LuaJIT an ideal technology for numerical computing. Additional advantages include:
- No compile step: testing and debugging are easy as changes to the code are immediately observed and there is no need to recompile programs for different operating systems
- Easy to interface with other languages:
- Small and portable: the Universal Package has a compressed size of 2 megabytes and supports Windows, OSX and Linux
- Very liberal MIT licensing for LuaJIT and Scilua: they can be used for any purpose, including commercial purposes, at absolutely no cost
The goal of SciLua is to offer a complete framework for scientific computing based on LuaJIT. The focus is on simple - to use, understand and implement - but provably successful algorithms. The code base is 100% pure Lua and external libraries are used only for very specialized numerical tasks, which often require hand-tuned CPU-dependent machine code for optimal performance, and for system bindings. The implementation of the algorithms is easy to follow lacking low-level language distractions thus lowering the barrier for contributions to our work.
Learning Lua
To make the most out of the SciLua framework it is suggested to invest a small amount of time into properly learning the Lua language. LuaJIT implements the 5.1 version of the language (with some features from 5.2).
The book "Programming in Lua - 2nd edition", written by Lua's authors, assumes no previous exposure and offers a clear and concise exposition of the language. Only parts 1 and 2, which respectively describe the language itself and its standard libraries, are relevant for the use of the SciLua framework.
Among the resources freely available we note:
- An introductory tutorial: Lua for Programmers
- The Lua 5.1 Reference Manual: http://www.lua.org/manual/5.1/
- The 1st edition of "Programming in Lua", aimed at Lua 5.0, which remains largely relevant: http://www.lua.org/pil/contents.html. For the complete list of changes between Lua 5.0 to Lua 5.1 see: http://www.lua.org/manual/5.1/manual.html#7