Nelua Programming Language

Minimal, simple, efficient, statically typed, compiled, meta programmable, safe and extensible systems programming language with a Lua flavor.

Overview Download Try Online

What is Nelua?

Nelua is a systems programming language for performance sensitive applications, like real-time applications and game engines. It has syntax and semantics similar to Lua, but is designed to be able to work with optional garbage collection, type notations and free from an interpreter. It uses ahead of time compilation to compile to optimized native binaries, is meta programmable at compile-time using Lua and is simple to use.

Read language overview
-- Calculates the factorial of a number.
local function factorial(n: integer): integer
  if n == 0 then
    return 1
    return n * factorial(n - 1)

local n = 5
local res = factorial(n)
print(n, 'factorial is', res)
-- Sum numbers from 1 to 10.
local sum = 0
for i = 1, 10 do
  sum = sum + i
print('The sum is', sum)
-- Print "hello world" manipulating strings.
require 'string'

local s1 = 'olleh'
local s2 = 'dlrow'

print(s1:reverse() .. ' ' .. s2:reverse())
-- Create and print a record data structure.
require 'string'
local Person = @record{
  name: string,
  age: integer
local person: Person = {name = "John", age = 20}
print(, 'is', person.age, 'years old')
Statically typed

Nelua takes advantage of type notations to do type checks at compile time and to generate efficient specialized code, most of the type notations are optional and the compiler can infer them at compile time.


Nelua should be efficient as C when programming with manual memory management and more efficient than Lua when using the optional garbage collector.


Nelua is simple and intuitive as Lua. Just some additions like type notations, efficient data structures and meta programming utilities are incremented over Lua but all those are optional.

Lua flavored

If you know how to code in Lua then you probably know how to code in Nelua already because it tries to have the same syntax, semantics, features and APIs.


Nelua takes advantage of ahead of time compilation using powerful optimized C compilers such as GCC or Clang thus generating very efficient native code, it doesn't use an interpreter at runtime.


Nelua is provide mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Nelua is not an object-oriented language, it does provide mechanisms for implementing classes and inheritance efficiently at compile time with meta programming.


Nelua tries to be safe by default for the user by minimizing undefined behavior, doing compile time checks and runtime checks.

Low level

Nelua has C like features to work at low level to allow micro optimizing parts of the code when needed.

Meta programmable

Nelua keeps its host features minimal and provides meta programming mechanisms to bring new features, allowing the semantics to be extended in unconventional ways at compile time. For example Nelua allows to create generics, polymorphic functions and specialize code at compile time using Lua and using its concepts system.


Nelua's compiler is written in Lua and is completely modifiable on the fly via the preprocessor, thus you can make unconventional techniques on the compiler at compile time, allowing for example to manipulate the AST, extend the language syntax, semantics or code generator.

C Compiles to C

Nelua compiles to C first then to native, thus you can read and debug the generated C code, mix other C code without costs, create or use C libraries, use C tools and reuse the generated C code. You can think of Nelua being a "better C" heavily inspired by Lua.

Run anywhere

Nelua uses minimal dependencies this means you can use it for any system that C is available, including the web.

Optional GC

Nelua uses a garbage collector by default but it's completely optional and can be replaced by manual memory management to have predictable runtime performance to use in real-time applications such as game engines and operational systems.

Self contained

Nelua doesn't use external dependencies, its standard library is written in Nelua and you only need a C compiler to use it.

Benchmark Lua LuaJIT Nelua C
ackermann 1070.4 ms 125.0 ms 38.9 ms 38.4 ms
fibonacci 2118.4 ms 914.8 ms 305.2 ms 305.1 ms
mandel 1212.3 ms 96.8 ms 88.3 ms 88.1 ms
sieve 1077.5 ms 266.1 ms 87.1 ms * 58.4 ms
heapsort 1483.2 ms 276.5 ms 158.4 ms * 125.3 ms

Lua 5.4, LuaJIT 2.1, GCC 10.1 were used in the benchmarks.


Nelua is very efficient, these are some benchmarks for equivalent code run in Nelua, Lua, LuaJIT and C.

* Nelua can match C performance when using optimized structures and doing manual memory management, however to do justice with Lua in the comparisons the benchmarks were coded in the same style, i.e. using the garbage collector and table like structures.


Use your terminal to install Nelua

Requires git, build tools and a C compiler. On Windows you should use MSYS2 with mingw-w64, on Linux you can use GCC and on MacOS you can use Clang.

Read installation docs
git clone
cd nelua-lang
make install
nelua examples/helloworld.nelua

Why Nelua?

Nelua is being created by a Lua lover who after years working with Lua in game projects wished a Lua flavored, efficient, simple and powerful at compile time language to replace C/C++ codes of game projects. If you have more questions read the frequently asked questions.

Learn more

Go to the documentation to learn more about what Nelua can do and how to use it.

Read documentation

Open Source

The Nelua compiler is open source and licensed under the MIT license, with most development taking place on GitHub. Be sure to watch the repository to get updates on Nelua's development and star it to incentive the project.

Support Nelua

If you like Nelua please consider contributing in some way, the simplest would be giving a star on GitHub or you could also try out Nelua and share your experience, report bugs, join the discord chat, spread it to the world, share something created with it, make blog post about it or make a donation.