• Stars
    star
    3,084
  • Rank 14,587 (Top 0.3 %)
  • Language
    C++
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

A fast, small, safe, gradually typed embeddable scripting language derived from Lua

Luau CI codecov

Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua.

It is designed to be backwards compatible with Lua 5.1, as well as incorporating some features from future Lua releases, but also expands the feature set (most notably with type annotations). Luau is largely implemented from scratch, with the language runtime being a very heavily modified version of Lua 5.1 runtime, with completely rewritten interpreter and other performance innovations. The runtime mostly preserves Lua 5.1 API, so existing bindings should be more or less compatible with a few caveats.

Luau is used by Roblox game developers to write game code, as well as by Roblox engineers to implement large parts of the user-facing application code as well as portions of the editor (Roblox Studio) as plugins. Roblox chose to open-source Luau to foster collaboration within the Roblox community as well as to allow other companies and communities to benefit from the ongoing language and runtime innovation.

This repository hosts source code for the language implementation and associated tooling, documentation for the language as well as RFCs and other materials. The documentation portion of this repository can be viewed at https://luau-lang.org/

Usage

Luau is an embeddable language, but it also comes with two command-line tools by default, luau and luau-analyze.

luau is a command-line REPL and can also run input files. Note that REPL runs in a sandboxed environment and as such doesn't have access to the underlying file system except for ability to require modules.

luau-analyze is a command-line type checker and linter; given a set of input files, it produces errors/warnings according to the file configuration, which can be customized by using --! comments in the files or .luaurc files. For details please refer to type checking and linting documentation.

Installation

You can install and run Luau by downloading the compiled binaries from a recent release; note that luau and luau-analyze binaries from the archives will need to be added to PATH or copied to a directory like /usr/local/bin on Linux/macOS.

Alternatively, you can use one of the packaged distributions (note that these are not maintained by Luau development team):

  • macOS: Install Homebrew and run brew install luau
  • Arch Linux: From the AUR (Arch Linux User Repository), install one of these packages via a AUR helper or manually (by cloning their repo and using makepkg): luau (manual build), luau-git (manual build by cloning this repo), or luau-bin (pre-built binaries from releases)
  • Alpine Linux: Enable community repositories and run apk add luau

After installing, you will want to validate the installation was successful by running the test case here.

Building

On all platforms, you can use CMake to run the following commands to build Luau binaries from source:

mkdir cmake && cd cmake
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build . --target Luau.Repl.CLI --config RelWithDebInfo
cmake --build . --target Luau.Analyze.CLI --config RelWithDebInfo

Alternatively, on Linux/macOS you can use make:

make config=release luau luau-analyze

To integrate Luau into your CMake application projects as a library, at the minimum you'll need to depend on Luau.Compiler and Luau.VM projects. From there you need to create a new Luau state (using Lua 5.x API such as lua_newstate), compile source to bytecode and load it into the VM like this:

// needs lua.h and luacode.h
size_t bytecodeSize = 0;
char* bytecode = luau_compile(source, strlen(source), NULL, &bytecodeSize);
int result = luau_load(L, chunkname, bytecode, bytecodeSize, 0);
free(bytecode);

if (result == 0)
    return 1; /* return chunk main function */

For more details about the use of host API you currently need to consult Lua 5.x API. Luau closely tracks that API but has a few deviations, such as the need to compile source separately (which is important to be able to deploy VM without a compiler), or lack of __gc support (use lua_newuserdatadtor instead).

To gain advantage of many performance improvements it's highly recommended to use safeenv feature, which sandboxes individual scripts' global tables from each other as well as protects builtin libraries from monkey-patching. For this to work you need to call luaL_sandbox for the global state and luaL_sandboxthread for each new script's execution thread.

Testing

Luau has an internal test suite; in CMake builds it is split into two targets, Luau.UnitTest (for bytecode compiler and type checker/linter tests) and Luau.Conformance (for VM tests). The unit tests are written in C++, whereas the conformance tests are largely written in Luau (see tests/conformance).

Makefile builds combine both into a single target and can be ran via make test.

Dependencies

Luau uses C++ as its implementation language. The runtime requires C++11, whereas the compiler and analysis components require C++17. It should build without issues using Microsoft Visual Studio 2017 or later, or gcc-7 or clang-7 or later.

Other than the STL/CRT, Luau library components don't have external dependencies. The test suite depends on doctest testing framework, and the REPL command-line depends on isocline.

License

Luau implementation is distributed under the terms of MIT License. It is based on Lua 5.x implementation that is MIT licensed as well.

When Luau is integrated into external projects, we ask to honor the license agreement and include Luau attribution into the user-facing product documentation. The attribution using Luau logo is also encouraged.

More Repositories

1

roact

A view management library for Roblox Lua similar to React
Lua
562
star
2

creator-docs

Open Source Creator Documentation
TypeScript
299
star
3

react-lua

A comprehensive translation of upstream React 17.x into Luau. This is a read-only mirror.
Lua
274
star
4

Core-Scripts

All of ROBLOX's core client scripts.
Lua
248
star
5

rodux

A state management library for Roblox Lua inspired by Redux
Lua
246
star
6

nomad-driver-containerd

Nomad task driver for launching containers using containerd.
Go
214
star
7

testez

BDD-style test and assertion library for Roblox Lua
Lua
183
star
8

foreman

Toolchain manager for Roblox projects
Rust
168
star
9

roblox-blender-plugin

A Blender plugin to upload selected assets in Blender to Roblox using Roblox's Open Cloud API.
Python
113
star
10

tarmac

Command line tool to manage Roblox assets
Rust
109
star
11

avatar

Avatar templates and assets available to our external developers
Lua
99
star
12

StudioWidgets

Lua
91
star
13

roact-rodux

A connector between Roact and Rodux, similar to react-redux
Lua
82
star
14

future-is-bright

Prototyping future Roblox lighting technology
60
star
15

js-to-lua

Conversion tool for migrating JS/TS code into Luau. This is a read-only mirror
TypeScript
54
star
16

voice-safety-classifier

Voice safety classifier
Python
51
star
17

nomad-driver-iis

Nomad task driver for running windows IIS services.
Go
50
star
18

Studio-Tools

Built-in ROBLOX Studio Lua plugins
49
star
19

nomad-node-problem-detector

NNPD - nomad-node-problem-detector
Go
47
star
20

Old-Open-Source-Levels

A repository of ROBLOX levels that are free to manipulate however you wish
36
star
21

rs-consul

This crate provides access to a set of strongly typed apis to interact with consul (https://www.consul.io/)
Rust
34
star
22

material-update-beta

29
star
23

rblx_nurd

Open Source Nomad Usage Resource Dashboard
Go
28
star
24

Wiki-Lua-Libraries

Lua
26
star
25

avatar-evolution

Prototyping the future of games and avatars on Roblox
23
star
26

setup-foreman

GitHub Action to install Foreman, a toolchain manager for Roblox tools
TypeScript
21
star
27

dash

A collection of core utilities expanding the capabilities of Luau. This is a read-only mirror.
Lua
17
star
28

cryo

A collection of methods for working with immutable data in a functional way for Luau. This is a read-only mirror.
Lua
15
star
29

luau-regexp

A regular expression library for Luau. This is a read-only mirror.
Lua
15
star
30

jest-roblox

Delightful testing for Luau. This is a read-only mirror.
Lua
15
star
31

signal-lua

A well-structured, well-tested, and well-documented Luau signal implementation. This is a read-only mirror.
Lua
14
star
32

cla-signature-bot

GitHub Action for self-contained handling of CLA signatures
TypeScript
14
star
33

Catalog

The virtual gear items which make up the Roblox catalog
14
star
34

luau-polyfill

A set of utilities to mimic common JS polyfills needed for translating projects from JS to Luau. This is a read-only mirror.
Lua
13
star
35

rbx-test-files

A repository of small Roblox model and place files to exercise implementations
Lua
13
star
36

graphql-lua

A reference implementation of GraphQL for Luau. This is a read-only mirror.
Lua
12
star
37

chalk-lua

Terminal string styling library for Luau. This is a read-only mirror.
Lua
11
star
38

otter

Declarative animation library for Luau. This is a read-only mirror.
Lua
10
star
39

zen-observable-lua

An Implementation of Observables for Luau. This is a read-only mirror.
Lua
10
star
40

roact-navigation

A declarative navigation system for App UI, built on top of Roact. This is a read-only mirror.
Lua
9
star
41

rhysd-github-action-benchmark

GitHub Action for continuous benchmarking to keep performance Copied from https://github.com/rhysd/github-action-benchmark
TypeScript
9
star
42

picomatch-lua

Blazing fast and accurate glob matcher written in Luau. This is a read-only mirror.
Lua
8
star
43

UnicodeVisualizerPlugin

Deprecated Roblox Studio plugin for visualizing strings of unicode. Use the web version. https://tiffnix.com/unicode/
Lua
8
star
44

symbol-luau

A simple, stable implementation of Symbol in Luau. This is a read-only mirror.
Lua
7
star
45

TweenService-Editor

TweenService Visual Editor plugin for Roblox Studio
Lua
6
star
46

luau-tag-utils

Utility functions to query Instances from tags attached with CollectionService. This is a read-only mirror.
Lua
5
star
47

apollo-client-lua

Apollo Client for GraphQL translated to Luau. This is a read-only mirror.
Lua
5
star
48

chef-teamcity

TeamCity Chef cookbook
Ruby
4
star
49

cla-bot-store

Storage repository for CLA bot. Public so that forks can check the signature file directly.
4
star
50

dom-testing-library-lua

Simple and complete testing utilities that encourage good testing practices. This is a read-only mirror.
Lua
3
star
51

roact-performance-benchmarks

Performance benchmarks for Roact. This a read-only mirror
Lua
3
star
52

test-repo-2022080901

3
star
53

graphql-tag-lua

A Luau template literal tag that parses GraphQL queries. This is a read-only mirror.
Lua
3
star
54

data-tools

Java
2
star
55

strongdm-contrib

contributions to strongdm to help with security operations and automation
Python
2
star
56

react-testing-library-lua

Simple and complete testing utilities that encourage good testing practices. This is a read-only mirror.
Lua
1
star
57

chef-xcode

Ruby
1
star
58

.github

GitHub Meta-Repo
1
star
59

action-creator-docs-automation

GitHub Actions for Creator Docs
1
star