Nelua is a language that I've wished after years making game engines in C/C++/Lua. It's my take on making a language that is compiled, efficient and simple with Lua syntax and semantics. It compiles first to C then to native code. You could think of it as a "better C" with a Lua syntax/goodies and type notations, but it's much more. Nelua is influenced by Nim, Odin and Zig languages, all of them tries to be a "better C", so does Nelua, but with a Lua flavor.
This program will print the factorial of 5.
In short Nelua is a minimal, simple, efficient, statically typed, compiled, meta programmable, safe and extensible systems programming language with a Lua flavor. It uses ahead of time compilation to compile to native code. Nelua stands for Native Extensible Lua.
Try it in REPL.it
You can try Nelua on the REPL.it here.
There are many examples in the
tests folder that you can run like
nelua examples/condots.nelua (this one is graphical and it will open X11) inside REPL.it.
To learn about the language features the
examples/overview.nelua is the most interesting to run and you can follow it along the overview page.
Here are some small games made in pure Nelua, all of them you can play in the browser and check the sources!
https://edubart.github.io/nelua-tetris/ - Tetris game
https://edubart.github.io/nelua-game2048/ - Clone of 2048 game
https://github.com/Andre-LA/baixada-game-jam-game - Castle Game - play here
Nelua compiler is made in pure Lua, and consists in 4 passes:
1. Use LPEG for parsing all the syntax into an AST
2. Analyze the AST for checking and inferring types
3. Generate C code using the analyzed AST
4. Compile the C code using a C compiler such as GCC/Clang
You will notice some C code in the repository but that's because I've bundled Lua 5.4 interpreter with needed extensions to make easy to install Nelua on REPL or any machine.
One thing interesting about Nelua is that it has a Lua preprocessor with powerful meta programming capabilities that gives full access to the compiler itself while it's compiling and assists specializing efficient static code.
NOTE: I've been making this language for more than one year, although I've been very active the whole month developing this language and polishing some stuff for the JAM.