Thrust official banner

Thrust Programming Language

A general-purpose, statically typed systems programming language for writing verbose, accurate, and fast code.

Philosophy

Thrust exposes memory operations, data layout, explicit memory alignment, calling conventions, and target information in the source code while providing high-level zero cost abstractions with simplicity.

Thrust keeps memory management direct and simple. The programmer controls allocation, pointer validity, resource lifetime, and the exact point at which memory is released, as in C.

Downloads

Package manager

Compiler

Quickstart

torio toolchain install
torio new fibonacci
torio run
// content: main.thrust
import std::io;

fn fibonacci [T] (n: T) T @public {
    if n <= 0 { return 0; }
    if n == 1 { return 1; }

    var a: T = 0;
    var b: T = 1;
    var i: T = 2;
    var result: T = 0;

    while i <= n {
        result = a + b;
        a = b;
        b = result;
        i++;
    }

    return result;
}

fn main() s32 @public {
    var result: s32 = fibonacci[s32](10);
    // Expected result: fib(10) = 55
    io::print("fib(%d) = %d\n", 10, result);
    return 0;
}

C-Style Clarity

A familiar C-style mental model with explicit control.

Generics at Compile Time

Generic functions and structures, specialized at compile time.

C Interoperability

Direct interop with C code via @extern and @convention("C").

Compile-Time Conditionals

Use @if, @elif, and @else to select platform-specific code at compile time.

Useful Imports

Mix std:: modules, aliases, and selective imports.

Built-in Compile Helpers

Type/layout builtins like sizeOf, alignOf, and isSameType for safer code.

Scope-Based Ownership

Automatic deallocation at scope exit, with no runtime ownership tracking. Memory is released exactly when the scope ends.

Ahead-of-Time and JIT

Native binaries ahead-of-time, or run through the JIT.

Zero-Cost Abstractions

Generics are specialized and dead branches removed at compile time.

Explicit Memory and Target Control

Direct control of layout, alignment, calling conventions, and targets.