Nelua Lang Save

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

Project README

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 wiki page 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

Open Source Agenda is not affiliated with "Nelua Lang" Project. README Source: edubart/nelua-lang

Open Source Agenda Badge

Open Source Agenda Rating