Sn Tin

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.

  1. 01Hello, TinWrite a program, run it, and read an error message.
  2. 02Values and typeslet, var, numbers, strings and how Tin infers types.
  3. 03FunctionsParameters, return types and functions that are one expression.
  4. 04Control flowif, loops and ranges. Most things are expressions.
  5. 05Structs and methodsGroup values into a type and give it methods.
  6. 06Sum types and matchA value that is one of several shapes, and a match that handles every one.
  7. 07Option, Result and ?No null and no exceptions: missing values and failures are ordinary values.
  8. 08Arrays and mapsLists of values, lookups by key, and the methods you use every day.
  9. 09Closures and pipelinesFunctions as values, and |> to chain them.
  10. 10GenericsOne function or type for many element types.
  11. 11Values, var and inoutEvery value is a copy. How you change things anyway, and why it helps.
  12. 12Durations and frequenciesUnits are types: 250ms + 3 does not compile.
  13. 13ModulesSplit a program across files with import.
  14. 14Teststest blocks next to the code, run with tin test.

Part 2. Agents

Agents, tools and approval as part of the language, checked by the compiler.

  1. 15Your first agentAn agent block, called like a function.
  2. 16ToolsGive an agent functions to call. Their schemas come from your types.
  3. 17Typed repliesAsk for a struct and get a struct back, not text to parse.
  4. 18Guarded tools and approvalA person approves every call to a dangerous tool.
  5. 19CapabilitiesThe compiler proves what each agent can reach.
  6. 20Sub-agents and teamsAgents that call agents: planners, workers and critics.
  7. 21spawn, await and withinRun agents at the same time, cancel them, and give them a time budget.
  8. 22Code as actionAn agent that answers with a small, checked Tin program.
  9. 23Record and replaySave every model answer to a tape and run it again offline.
  10. 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.

  1. 25Calling JavaScriptimport js and extern fn, checked at the boundary.
  2. 26A fleet of agentsA larger program, read piece by piece.
  3. 27A command-line tooltin new, input, formatting and building a .wasm.
  4. 28Tin in the browserWhat runs in the playground and how agents work there.