TYCHO Search

Search documentation

    ↑ ↓ to move · Enter to open · Esc to close

    Experimental · v0.9.2

    Tycho is a systems
    programming language.

    Tycho compiles to native code and handles memory without a garbage collector. It’s built for parsers, interpreters, and other programs that work with lots of temporary data.

    A small Tycho programTycho
    fn evens(limit: int) -> [int]:
        xs := []int
        for i := 0; i < limit; i += 1:
            if i % 2 == 0:
                push(xs, i)
        return xs
    
    fn main():
        xs := evens(10)
        println(str(len(xs)))   # 5

    This program collects the even numbers below 10 and prints how many it found. You don’t have to allocate or free the array yourself.

    Native code via C Open source · MIT Pre-1.0 · expect breaking changes
    Memory management

    The compiler handles the cleanup.

    You can create an array inside a function and return it without deciding who will free it. Tycho works out where the data belongs from the code. You don’t write lifetime annotations or calls to free.

    Automatic cleanupTycho groups allocations into arenas—blocks of memory tied to a scope, such as a function or code block. When the owning scope ends, its memory is freed. Returned data is stored in the caller’s arena.
    Independent valuesAn assignment gives you your own copy of an array or struct. Change that copy, and the original stays as it was. This is called value semantics.
    Native executablesTycho produces C code and uses GCC or Clang to build the final program. It can call C libraries too.

    The memory guide explains how this works, starting from familiar C code. There are also limits to the model, described below.

    The language

    Language features.

    Tycho uses indentation rather than braces to group code. Alongside functions, strings, arrays, maps, and structs, it includes:

    Corelib packages cover files, text, networking, and other common tasks. You import packages by path; there’s no package manager.

    The tutorial starts with small programs. For individual features and corelib packages, see the reference.

    Explore the source

    Programs written in Tycho.

    I’ve used Tycho to build a Scheme interpreter, an HTTP server, and a chess engine. Their source is included so you can read the code and run them yourself.

    Scheme interpreterAn interpreter and bytecode compiler for Scheme, including closures.
    HTTP key-value serverA key-value store served over HTTP, with several workers handling requests.
    Chess engineGenerates legal moves and searches the game tree to choose a move.

    There’s also a compiler written in Tycho. You can find timings, memory use, and how they were measured in the benchmarks.

    Before you choose it

    What you give up.

    Shared pointers and runtime interfaces aren’t part of Tycho. If your program relies on them, you’ll need to change its design.

    Graphs and linked structuresInstead of pointers between nodes, use arrays of nodes linked by integer indices. Thinking in Tycho shows how.
    Memory tradeoffsTemporary data can stay allocated until its owning scope ends. A long-running function may keep memory it no longer needs. Some structures also need more memory than C versions; the measurements show how much.
    No interface valuesYou can’t store values of different types behind one interface. Use generics for code that works with several types, or enums for a fixed set of cases.
    Still experimentalBefore 1.0, I may change the language and corelib APIs without a deprecation period. I’m looking for developers to try Tycho in their own projects and tell me what needs work. See the version policy and roadmap.

    I still need a full independent security audit before 1.0. Don’t use Tycho for security-critical work. C interop can also introduce memory errors; see the security policy.

    Get started

    Build and run a program.

    Building from source needs Git, make, and a C11 compiler (GCC or Clang 15+). The platform guide has setup instructions for your system.

    Run the hello exampleTerminal
    $ git clone https://github.com/StefanVonRanda/tycho
    $ cd tycho
    $ make
    $ ./tychoc examples/hello.ty && ./examples/hello
    built examples/hello
    what is your name: Ada
    hello Ada

    Type Ada when the program asks for your name.

    Prebuilt compilers and checksums are on the v0.9.2 release page. You’ll still need a C compiler to build your programs.

    Documentation

    Start with the tutorial.