Learn Tin today
From your first line to an agent with tools, in short chapters. Each one is a few minutes of reading, a handful of programs you can run, and a few tasks with solutions.
Read the parts in order: Part 2 uses everything from Part 1. Every program on these pages is a
real file in examples/learn/. It was compiled and run when this page was built, and the output
shown is what it printed. Already write TypeScript or Rust and just want a look? The
15-minute tour is faster.
Part 1. The language
Values, functions, types, errors and collections. Everything you need before agents.
- 01Hello, TinWrite a program, run it, and read an error message.
- 02Values and types
let,var, numbers, strings and how Tin infers types. - 03FunctionsParameters, return types and functions that are one expression.
- 04Control flow
if, loops and ranges. Most things are expressions. - 05Structs and methodsGroup values into a type and give it methods.
- 06Sum types and matchA value that is one of several shapes, and a
matchthat handles every one. - 07Option, Result and ?No null and no exceptions: missing values and failures are ordinary values.
- 08Arrays and mapsLists of values, lookups by key, and the methods you use every day.
- 09Closures and pipelinesFunctions as values, and
|>to chain them. - 10GenericsOne function or type for many element types.
- 11Values, var and inoutEvery value is a copy. How you change things anyway, and why it helps.
- 12Durations and frequenciesUnits are types:
250ms + 3does not compile. - 13ModulesSplit a program across files with
import. - 14Tests
testblocks next to the code, run withtin test.
Part 2. Agents
Agents, tools and approval as part of the language, checked by the compiler.
- 15Your first agentAn
agentblock, called like a function. - 16ToolsGive an agent functions to call. Their schemas come from your types.
- 17Typed repliesAsk for a struct and get a struct back, not text to parse.
- 18Guarded tools and approvalA person approves every call to a dangerous tool.
- 19CapabilitiesThe compiler proves what each agent can reach.
- 20Sub-agents and teamsAgents that call agents: planners, workers and critics.
- 21spawn, await and withinRun agents at the same time, cancel them, and give them a time budget.
- 22Code as actionAn agent that answers with a small, checked Tin program.
- 23Record and replaySave every model answer to a tape and run it again offline.
- 24Real modelsSwap the mock for a real model. Nothing else changes.
Part 3. Real programs
Calling JavaScript, a fleet of agents, a command-line tool and the browser.