Nelua
source link: https://nelua.io/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Nelua
What is Nelua?
Nelua is a systems programming language for performance sensitive applications, like real-time applications and game engines. Its syntax and semantics are similar to Lua, but its garbage collection is optional, it provides optional type notations, and it is free from an interpreter. Nelua uses ahead-of-time compilation to generate optimized native binaries. It is metaprogrammable at compile-time using Lua and it is simple and easy to use.
Read language overview-- Calculates the factorial of a number.
local function factorial(n: integer): integer
if n == 0 then
return 1
else
return n * factorial(n - 1)
end
end
local n = 5
local res = factorial(n)
print(n, 'factorial is', res)
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 as efficient as C when programming with manual memory management, and more efficient than Lua when using the optional garbage collector.
Nelua is as simple and intuitive as Lua. Some additions like type notations, efficient data structures, and metaprogramming utilities are available, unlike Lua, but all of them are optional.
If you know how to code in Lua then you probably know how to code in Nelua. 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, and thus generates very efficient native code. No interpreter is needed at runtime.
Nelua provides 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 via metaprogramming.
Nelua tries to be safe by default for the user by minimizing undefined behavior and doing both compile-time checks and runtime checks.
Nelua has C-like low level features to allow micro-optimizing parts of the code when needed.
Nelua keeps its host features minimal and provides metaprogramming mechanisms, allowing the semantics to be extended in unconventional ways at compile time. For example, Nelua allows you to create generics, polymorphic functions, and specialized code at compile time using Lua and using the concepts system.
Nelua's compiler is written in Lua and is completely modifiable on the fly via the preprocessor, thus you can change the behavior of the compiler at compile time, allowing, for example, direct manipulation of the AST, or even extensions to the language syntax, semantics, or the code generator.
Nelua compiles to C first then to native code, thus you can read and debug the generated C code, mix in other C code without costs, create or use C libraries, use C tools, and reuse the generated C code. You can think of Nelua like a "better C" heavily inspired by Lua.
Nelua has minimal dependencies. This means you can use it for any system where C is available, including the web.
Nelua uses a garbage collector by default, but it is completely optional and can be replaced by manual memory management for predictable runtime performance and for use in real-time applications, such as game engines and operational systems.
Nelua does not use external libraries. Its standard library is written in Nelua and you only need a C compiler to use it.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK