Teal – A statically-typed dialect of Lua
Teal: A Statically-Typed Evolution of Lua
Teal is a specialized dialect of the Lua programming language that introduces static typing. By adding type annotations, it allows developers to define complex structures such as:
| Feature | Description |
|---|---|
| Records & Maps | Structured data and key-value pairs |
| Arrays | Typed sequences of elements |
| Interfaces | Defined contracts for object shapes |
| Union Types | Variables that can hold multiple types |
| Generics | Flexible, reusable type definitions |
Teal aims to occupy a space similar to what TypeScript provides for JavaScript, while remaining faithful to Lua's core philosophy of
bloatminimalism, portability, and ease of embeddability.
How it Works
Teal is not a runtime; it is implemented as a compiler called tl. This tool transforms source files with the .tl extension into standard .lua files.
A Glimpse of the Syntax
In Teal, you can explicitly define the types of function arguments and return values. For example, a simple addition function would be represented mathematically as , and written in code as:
local function add(a: number, b: number): number
return a + b
end
local s = add(1, 2)
print(s)
Want to try it out? You can experiment with the language via the Teal Playground in your web browser or examine the source code of the official website.
Getting Started
To begin using Teal, follow these steps:
- Install the Compiler
If you have
LuaRocksinstalled, run:luarocks install tl(Alternatively, download pre-compiled binaries for Windows or Linux). - Set Up Your IDE
- For Visual Studio Code: Install
vscode-teal. - For NeoVim and others: Use
teal-language-server.
- For Visual Studio Code: Install
- Manage Projects
For larger codebases, avoid running
tlon files individually; use a build script or task runner.
Knowledge Base & History
The evolution of Teal has been documented through several presentations regarding the tension between minimalism and type systems:
- 2019: Minimalism versus types
- 2020: Minimalistic typed Lua is here
- 2021: What's next for Teal
- 2024: Five years of Teal: minimalism versus growth in language design
- 2025: What should Teal be? (Reflections on the direction of FOSS projects)
Community & Origin
Teal was originally conceived by Hisham Muhammad. Today, it is maintained by a growing collective of contributors. In a feat of "bootstrapping," the language is actually written in Teal itself.
Connect with the community:
- Development: Hosted on GitHub.
- Chat: Join the conversation on Matrix at
#teal-language_community:gitter.im.