Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Get Started

InstallationGetting StartedCLI

Tutorial

Build a CLI with Tea1. Display your first task2. Display several tasks3. Track task status4. Accept commands5. Read saved tasks6. Add tasks7. Complete tasks8. Organize and test9. Build your executable

Language

SyntaxTypesFunctionsStructsGenericsPattern MatchingError HandlingModulesTesting

Project

Code StyleContributing

Read as Markdown

Language

Syntax

Tea uses `var` and `const`, block endings with `end`, backtick interpolation, and expression-friendly control flow.

Tea keeps the surface syntax small. Most files are built from a few recurring pieces: bindings, blocks that end with end, control flow, and strings with backtick interpolation.

This page focuses on how code is written, not on the full type system. If you are learning the language, these are the forms you will see first in everyday Tea programs.

Bindings, blocks, and if

Local values use const and var. Control-flow blocks start with a keyword such as if and always close with end.

const is_debug = true
var label = "tea"

if is_debug
  label = "tea (debug)"
else
  label = "tea"
end

const mode = if(is_debug) "verbose" else "normal"

@println(label)
@println(mode)

Loops

Tea supports both while loops for condition-driven repetition and for ... in ... loops for iterating collections.

var count = 0

while count < 3
  @println(count)
  count = count + 1
end

const names = ["tea", "chai"]

for name in names
  @println(name)
end

When iterating dictionaries, you can bind both the key and value directly in the loop header.

const scores = {"tea": 10, "chai": 8}

for name, score in scores
  @println(`${name}: ${score}`)
end

Strings and interpolation

String lengths (@len), bracket indices, slice bounds, and substring search positions count Unicode scalars in both native and browser execution. For example, @len("café🍵") is 5, "café🍵"[4] is "🍵", and "café🍵"[3..5] is "é🍵". Combining marks and parts of joined emoji count separately; Tea does not normalize text.

String slices exclude the endpoint with .. and include it with .... The end is clamped to the string length. The start may equal the length for an empty slice; negative bounds, a start beyond the length, or a start greater than the clamped end are errors.

Use double quotes for ordinary strings and backticks when you want interpolation. Expressions inside a backtick string use ${...} placeholders.

var name = "Tea"
var version = 1
@println(`${name} v${version}`)

Core syntax rules

  • Blocks end with end.
  • Use const for stable bindings and var for values you reassign.
  • if(expr) a else b is supported as an expression.
  • while and for ... in ... cover the core looping syntax.
  • Backticks enable string interpolation with ${...} placeholders.

Next steps

Continue to

Types

See list, dict, optional, and function types.

Continue to

Functions

Write named functions and lambdas.