Luau, a type-checked variant of the Lua language, is open source

Announced the open source and publication of the first standalone release of the Luau programming language, continuing the development of the Lua language and backward compatible with Lua 5.1. Luau is designed primarily for embedding scripting engines into applications and aims to achieve high performance and low resource consumption. The project code is written in C++ and is open under the MIT license.

Luau extends Lua with type checking capabilities and some new syntactic constructs such as string literals. The language is backward compatible with Lua 5.1 and partially with newer versions. The Lua Runtime API is supported, allowing you to use Luau with existing code and bindings. The language runtime is based on a heavily reworked Lua runtime 5.1 code, but the interpreter is completely rewritten. During development, some new optimization techniques were used to achieve higher performance compared to Lua.

The project was developed by Roblox and is used in the code of the gaming platform, games, and user applications of this company, including the Roblox Studio editor. Initially, Luau was developed behind closed doors, but in the end it was decided to transfer it to the category of open projects for further joint development with the participation of the community.

Main Features:

  • Gradual typing, occupying an intermediate position between dynamic and static typing. Luau allows you to use static typing as needed by specifying type information through special annotations. The built-in types "any", "nil", "boolean", "number", "string" and "thread" are provided. At the same time, the possibility of using dynamic typing without explicitly defining the type of variables and functions is preserved. function foo(x: number, y: string): boolean local k: string = y:rep(x) return k == “a” end
  • Support for string literals (as in Lua 5.3) such as "\0x**" (hexadecimal number), "\u{**}" (Unicode character) and "\z" (end of line), as well as the ability to visualize number formatting (you can write 1_000_000 instead of 1000000), literals for hexadecimal (0x...) and binary numbers (0b......).
  • Support for the "continue" expression, complementing the existing "break" keyword, to jump to a new loop iteration.
  • Support for compound assignment operators (+=, -=, *=, /=, %=, ^=, ..=).
  • Support for the use of conditional "if-then-else" blocks in the form of expressions that return the value calculated during the execution of the block. You can specify an arbitrary number of elseif expressions in a block. local maxValue = if a > b then a else b local sign = if x < 0 then -1 elseif x > 0 then 1 else 0
  • The presence of an isolation mode (sandbox), which allows you to run untrustworthy code. This feature can be used to organize the launch side by side of your own code and code written by another developer, for example, third-party libraries for the safety of which cannot be guaranteed.
  • A limitation of the standard library from which functions that could potentially create security problems have been removed. For example, the libraries “io” (accessing files and launching processes), “package” (accessing files and loading modules), “os” (functions for accessing files and changing environment variables), “debug” ( unsafe operation with memory), “dofile” and “loadfile” (FS access).
  • Providing tools for static code analysis, identifying errors (linter) and checking the correct use of types.
  • Own high-performance parser, bytecode interpreter and compiler. Luau does not yet support JIT compilation, but it is claimed that the Luau interpreter is quite comparable in performance to LuaJIT in some situations.

Source: opennet.ru

Add a comment