iyi

Playground

A tour of iyi, in 33 short programs.

Start at the top and work down. Read the program, press Run, see what it prints, then move to the next. Each one is a page you can come back to.

Start with hello →
  1. 01

    Welcome

    One program, to see the shape of the thing.
    1. 1helloYour first iyi program.
  2. 02

    Basics

    Modules, variables, types and functions: what every program is made of.
    1. 2modulesModules: every file is one, and import brings another in.
    2. 3exportsimport x::{...}: bring a module's exported names in, unqualified.
    3. 4variablesVariables: assign a value and the type follows.
    4. 5typesThe basic types, and what each literal is.
    5. 6conversionsConversions are explicit: nothing changes type on its own.
    6. 7constantsConstants: a capitalised name, assigned once.
    7. 8functionsFunctions: def, typed parameters, a typed result.
    8. 9returnsMore than one result: a tuple, unpacked at the call.
    9. 10nilnil is a value, and the type says whether it can appear.
  3. 03

    Flow control

    Loops, ranges, conditions, case, and cleanup with defer.
    1. 11loopsLoops: each over a collection, times, while, and loop.
    2. 12rangesRanges: .. includes the end, ... stops before it.
    3. 13conditionsConditions: if, elsif, else, unless, and if as a value.
    4. 14casecase: one value, many branches.
    5. 15deferdefer: name the cleanup where you acquire, run it when the scope ends.
  4. 04

    Data

    Structs, classes, arrays, hashes, tuples and blocks.
    1. 16structsA struct: named fields, a constructor, methods.
    2. 17classesA class is a reference: two names can point at one object.
    3. 18arraysArrays: ordered, growable, one element type.
    4. 19hashesHashes: keys to values, in insertion order.
    5. 20tuplesTuples: a fixed group of values, each with its own type.
    6. 21blocksBlocks and closures: code you hand to a function.
  5. 05

    Methods and traits

    Behaviour on types, traits that name it, unions and errors as values.
    1. 22methodsMethods: functions that belong to a type.
    2. 23traitsA trait: a set of methods a type promises to have.
    3. 24dispatchA trait is a type: one list, many kinds, one question.
    4. 25defaultsDefault methods: a trait can carry bodies of its own.
    5. 26unionsUnion types: a value that is one of several types.
    6. 27errorsErrors are values. A function that can fail says so in its type.
    7. 28stringsStrings, and to_s: how a type says what it looks like.
  6. 06

    Generics

    Functions and types that work for any type, and bounds that say which.
    1. 29generic-functionsGeneric functions: forall T makes a function work for any type.
    2. 30generic-typesGeneric types: a struct with a type parameter.
    3. 31boundsBounds: a generic that asks its type parameter for a trait.
  7. 07

    Concurrency

    Tasks in a group, and channels between them.
    1. 32tasks nativeTasks: run work at the same time, inside a group that waits for it all.
    2. 33channels nativeChannels: tasks talk by sending values, not by sharing them.

Done with the tour? Learn the one rule that makes iyi its own language, in eight lessons that each run a real program from the repository.

native Each program runs from the module the iyi compiler built for it, checked against its recording before it starts. A step marked native uses tasks, which the browser's target cannot run yet, so it shows what the program printed natively instead. You can type in any of the panes, and the page says which bytes a run will use the moment what is in one stops being the recorded file, because nothing on these pages compiles what you type. How this works