• Stars
    star
    1,914
  • Rank 23,622 (Top 0.5 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.

Nelua Logo

nelua.io

Test Status Discord

Nelua (stands for Native Extensible Lua) is a minimal, efficient, statically-typed and meta-programmable systems programming language heavily inspired by Lua, which compiles to C and native code.

Note: The language is in alpha state and still evolving.

Quick start

  • For basic information check the Website.
  • For first steps and how to use Nelua, start at the Tutorial.
  • For a tour of the language's syntax, features and usage read the Overview.
  • For small examples written in Nelua look the Examples folder .
  • For questions and discussions go to the Discussions.
  • For a chat with the community join the Discord server.
  • For cool stuff made with Nelua check Awesome Nelua repository and #showcase channel in the Discord server.

After installing, you might want to check out the featured example, a Snake game leveraging the famous SDL2 library:

nelua examples/snakesdl.nelua

About

Nelua is a systems programming language for performance-sensitive applications where Lua would not be efficient, such as operating systems, real-time applications and game engines. While it has syntax and semantics similar to Lua, it primarily focuses on generating efficient C code and provide support for highly-optimizable low-level programming. Using Nelua idioms such as records, arrays, manual memory management and pointers should result in performance as efficient as pure C; on the other hand, when using Lua idioms such as tables, metatables and untyped variables, the compiler will bake a runtime library for this sort of dynamic functionality into the program, which could incur some runtime overhead.

Nelua can do meta programming at compile time through preprocessor constructs written in Lua; since the compiler itself is also written in Lua, it means that user-provided preprocessor code can interact at any point with the compiler's internals and the source code's AST. Such system allows for ad-hoc implementation of high level constructs such as classes, generics and polymorphism, all without having to add them into the core specification, thus keeping the language simple, extensible and compact. The same way that Lua's object-oriented patterns are not built into the language, but can be nonetheless achieved through metatables, in Nelua you could yourself implement a similar functionality which is fully decided at compile time or dynamically dispatched at runtime.

Nelua can do extensible programming as the programmer may add extensions to the language such as new grammars, AST definitions, semantics, type checkers, code generation and behaviors to the compiler at compile time via the preprocessor.

Nelua provides support for both garbage-collected and manual memory management in a way that the developer can easily choose between using garbage collection, or completely disabling garbage collection, or mixing both.

Nelua first compiles to C, then it executes a C compiler to produce native code. This way existing C code and libraries can be leveraged and new C libraries can be created. Another benefit is that Nelua can reach the same target platforms as C99 compilers, such GCC or Clang, while also enjoying state-of-the-art compiler optimizations provided by them.

The initial motivation for its creation was to replace C/C++ parts of projects which currently uses Lua with a language that has syntax and semantics similar to Lua, but allows for fine-grained performance optimizations and does not lose the ability to go low level, therefore unifying the syntax and semantics across both compiled and dynamic languages.

Goals

  • Be minimal with a small syntax, manual and API, but powerful
  • Be efficient by compiling to optimized C code then native code
  • Have syntax, semantics and features similar to Lua
  • Optionally statically typed with type checking
  • Achieve classes, generics, polymorphism and other higher constructs by meta programming
  • Have an optional garbage collector
  • Make possible to create clean DSLs by extending the language grammar
  • Make programming safe for non experts by doing run/compile-time checks and avoiding undefined behavior
  • Possibility to emit low level code (C, assembly)
  • Be modular and make users capable of creating compiler plugins to extended
  • Generate readable, simple and efficient C code
  • Possibility to output freestanding code (dependency free, for kernel dev or minimal runtime)
  • No single memory management model, choose for your use case GC or manual

Why?

  • We love to script in Lua.
  • We love C performance.
  • We want best of both worlds in a single language and with a unified syntax.
  • We want to reuse or mix existing C/C++/Lua code.
  • We want type safety and optimizations.
  • We want to have efficient code while maintaining readability and safety.
  • We want the language features and manual to be minimal and fit our brain.
  • We want to deploy anywhere C runs.
  • We want to extended the language features by meta programming or modding the compiler.
  • We want to code with or without garbage collection depending on our use case.
  • We want to abuse of static dispatch instead of dynamic dispatch to gain performance and correctness.

Contributing

You can support or contribute to Nelua in many ways, giving the project a star on github, testing out its features, reporting bugs, discussing ideas, helping other users, spreading it to the world, sharing projects made with it on github, creating tutorials or blog posts, improving its documentation or through a donation or sponsorship.

Nelua is open source, but not very open to contributions in the form of pull requests, if you would like something fixed or implemented in the core language try first submitting a bug report or opening a discussion instead of doing a PR. The authors prefer it this way, so that the ideal solution is always provided, without unwanted consequences on the project, thus keeping the quality of the software.

Read more about contributing in the contributing page.

Become a Patron

License

MIT License

More Repositories

1

otclient

An alternative tibia client for otserv written in C++11 and Lua, made with a modular system that uses lua scripts for ingame interface and functionality, making otclient flexible and easy to customize
C++
634
star
2

minicoro

Single header stackful cross-platform coroutine library in pure C.
C
589
star
3

sokol_gp

Minimal modern efficient cross platform 2D graphics painter in C
C
416
star
4

minilua

Single-file port of Lua, a powerful scripting language.
C
233
star
5

minivorbis

Single-file port of libogg and libvorbis for decoding ogg sound files.
C
61
star
6

lpegrex

Parse programming languages syntax into an AST using PEGs with ease (LPeg Extension).
Lua
59
star
7

miniphysfs

Single-file port of PhysFS, a library that provides abstract access to various archives.
C
58
star
8

ddosmon

Live DDOS monitor in the command line using ncurses
C++
56
star
9

lua-bint

Arbitrary precision integer arithmetic library in pure Lua
Lua
55
star
10

luamon

Live development utility for Lua inspired by nodemon
Lua
55
star
11

nelua-decl

C binding generator for Nelua using GCC Lua plugin.
Lua
42
star
12

riscvm

Tiny RISC-V virtual machine
C
37
star
13

arraymancer-vision

Simple library for image loading, preprocessing and visualization for working with arraymancer.
Nim
29
star
14

nelua-batteries

Lua
27
star
15

tetrix

Tetris like game made in Nelua for RIV fantasy console
Lua
24
star
16

nelua-game2048

Clone of the 2048 game in Nelua using Raylib
Lua
22
star
17

nelua-vscode

Nelua syntax highlighting for Visual Studio Code
JavaScript
20
star
18

lester

Minimal Lua test framework
Lua
20
star
19

android-libs

Port of C++ libraries to Android that I use in my projects
C
17
star
20

antcopter

2D speed run platformer, originally made for the WASM4 game Jam, now also a game in RIVES.
Lua
17
star
21

lunray

Ray tracing experiment in Nelua programming language
Lua
14
star
22

arraymancer-demos

Demos and benchmarks of arraymancer (WIP)
Nim
14
star
23

nelua-sublime

Nelua syntax highlighting for Sublime Text
13
star
24

nelua-benchmarks

Benchmarks for comparing efficiency of Nelua with Lua, LuaJIT and C
Lua
13
star
25

forkmon

Watch for file changes and auto restart an application using fork checkpoints to continue the process (for quick live development)
C
12
star
26

nldoc

Tool to generate documentation for Nelua source files.
Lua
10
star
27

euluna-binder

Smart C++ binder for lua
C++
9
star
28

miniminiz

Miniz in a single C header.
C
8
star
29

srpmalloc

Fork of rpmalloc to be used with single thread applications and old C compilers
C
8
star
30

otml

OTML, a human readable and easy typing data serialization file format. This is a compact version of its emitter/parser extracted from OTClient in just one header with no dependencies.
C++
8
star
31

ioslibs

Build scripts that I use to build required libraries for my iOS projects
Shell
8
star
32

minialloc

Allocator using multiple pools for small allocations, in a single C header.
C
7
star
33

bwrapbox

Linux sandboxing utility on top of bubblewrap
C
7
star
34

marcherstein3d

Realtime pseudo 3D raycaster on the CPU using 2D ray marching
Lua
6
star
35

nelua-lsp

Experimenting creating a minimal LSP for Nelua to be used for tooling in text editors
Lua
5
star
36

nelua-vim

Vim plugin for Nelua, originally created by Stefanos
Vim Script
5
star
37

gcc-lua

Mirror of https://git.colberg.org/gcc-lua with minor fixes.
C
5
star
38

synack

Efficient network DDOS attacker tool for testing
C
5
star
39

lua-dumper

A small library for dumping lua variables quickly. This library is typically used for quick debugging values to the terminal where one would use print but want more information about the value (like table content), output to stderr by default (or other file handle) and optionally time elapsed.
Lua
5
star
40

nelua-webview-demo

Example using Nelua for WebView apps
C++
4
star
41

seqtoy

Toy music sequencer written in Nelua for RIV fantasy console
Lua
4
star
42

nelua-samples

Some sample applications write in Nelua
C
4
star
43

cartesi-wasm-term

Cartesi Machine interactive terminal in the browser
C++
4
star
44

cartesi-doom-example

Cartesi Machine running DOOM example
C
4
star
45

lua-hasher

A small library with hash and encoding functions implemented in C. Currently supports blake2b hashing and base58 encode/decode.
C
3
star
46

neuralnet

Simple and compact neural network in C using backpropagation algorithm
C
3
star
47

aoc

Advent of Code 2020 in Nelua
Lua
3
star
48

riv

RIV game framework - WIP
C
3
star
49

fwmonitor

Lua
2
star
50

nelua-decl-extra

Extra bindings for Nelua that I won't maintain regularly
Lua
2
star
51

osxlibs

Homebrew formulas that I use for compiling libraries for my Mac OS X projects
Ruby
2
star
52

TibiaEye

Old project that I've found lost in an old HD, it was a functional TibiaCam in Qt
C++
2
star
53

hypervisor-playground

Playing with hypervisor, running guest machines inside a host machine being emulated
Makefile
2
star
54

glwall

Simple experiment for animated wallpapers in Linux using GLSL shaders
C
1
star
55

edubart.github.com

Ruby
1
star
56

bladebomber

Game made during first RIVES game jam to demontrate RIV C API
C
1
star
57

edubart

GitHub profile
1
star