July 25, 2014 — April 21, 2023

computers are awful
number crunching
premature optimization
Figure 1

A handy embeddable scripting language from Brazil. Famous for being simple to embed in other things and yet fast.

I do not use a whole bunch of Lua. I spend most of my time working in python and R, and julia for the scientific/JIT stuff because there is more hype there. Lua is nonetheless helpful because it is embedded in such various things as DAW Renoise, sundry game engines and even latex these days.

Lua is low-fuss technology without much brand recognition… which is probably why it is useful. It already obviously does a good job being the embedded scripting language for other things. So the pitch is essentially “Lua is good because it a piece of boring infrastructure that you can use for interesting things”.

On that note…

1 Introductions

2 Utility

3 Numeric computations


This project is dedicated to libraries that support scientific computing with Lua using the LuaJIT hi-performance implementation of the language. We focus on libraries offering the following features:

  • pure Lua(JIT) code, no C compilation needed, trivial installation;
  • MIT free software license that allows for an easy integration with both open-source and proprietary projects;
  • well documented, concise interfaces to minimize learning curve;
  • efficient implementation. LuaJIT makes it possible to write code in a dynamic high-level language and still benefit from a performance competitive with that of statically compiled languages (C, C++, Fortran, …). It also makes it easier to re-use existing libraries written in C.

LuaJIT itself is a JIT-compiler for Lua; seems to predate a lot of the LLVM JIT compilers in circulation. this probably gets us numerical speed?

Terra “Use your favourite dynamic language (Lua) to implement a compiled DSL.”

In Terra, we just gave in to the trend of making the meta-language of C/C++ more powerful and replaced it with a real programming language, Lua.

Example use:

An embedded JIT-compiler for building languages. We use techniques from multi-stage programming2 to make it possible to meta-program Terra using Lua. Terra expressions, types, and functions are all first-class Lua values, making it possible to generate arbitrary programs at runtime. This allows you to compile domain-specific languages (DSLs) written in Lua into high-performance Terra code. Furthermore, since Terra is built on the Lua ecosystem, it is easy to embed Terra-Lua programs in other software as a library. This design allows you to add a JIT-compiler into your existing software. You can use it to add a JIT-compiled DSL to your application, or to auto-tune high-performance code dynamically.

Torch was popular in the artificial neural networks community and uses C, GPU (?) and LuaJIT together.

4 Fun things with Lua in

4.1 pandoc

pandoc, my favourite workhorse document parser, has a Lua interpreter. As utilitarian as that may sound, this is probably the killer app for me.

As a kind of special case of this, quarto the scholarly document editing/scientific workbook system, is also built using Lua Extensions.

4.2 Renoise

The audio production environment Renoise has an embedded Lua interpreter.

4.3 Protoplug

protoplug embeds a Luajit-based DSP and GUI engine in VST plugins.

4.4 Csound

Audio language csound also has a Lua interpreter, and can be embedded in Lua IIRC.

4.5 LÖVE

LÖVE is a Lua-scriptable game engine. Also looks like a fun way of making visuals, retro-2d-style.

4.6 LÖVR

LÖVR: An open source framework for rapidly building immersive 3D experiences.

4.7 LaTeX

Yes, even latex, via Luatex.

“The main objective of the project is to provide a version of TeX where all internals are accessible from Lua. In the process of opening up TeX much of the internal code is rewritten. Instead of hard coding new features in TeX itself, users (or macro package writers) can write their own extensions. LuaTeX offers native support for OpenType fonts. In contrast to XeTeX, the fonts are not accessed through the operating system libraries, but through a library based on FontForge.”

4.8 PICO-8

PICO-8 is a fantasy console for making, sharing and playing tiny games and other computer programs. It feels like a regular console, but runs on Windows / Mac / Linux. When you turn it on, the machine greets you with a commandline, a suite of cartridge creation tools, and an online cartridge browser called SPLORE.

4.9 Redis

Redis is a realtime database which has a lua interpreter.