Skip to content
@thrustlang

The Thrust Programming Language

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

logo

Thrust Programming Language

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

standard-separator

Thrust Programming Language

Thrust is a system programming language. It offers developers more precise control over system programming, similar to native C and C-like languages.

Thrust is essentially C, but at an even lower level.

However, Thrust also allows high-level abstractions when needed, providing a perfect balance between low-level control and modern productivity.

For example, Thrust enables embedding a linear assembler within the compilation process, offering direct control over architecture-specific code generation.

asmfn invoke_x86_64_exit_syscall() void
@asmSyntax("AT&T") @convention("C")
{
    "mov $$60, %rax",
    "mov $$1, %rdi",
    "syscall"
} { 
    "~{rax}~{rdi}"
}

fn main() s32 @public {
    invoke_x86_64_exit_syscall();
    return 0;
}

Exotic support

Thrust Programming Language supports unique architectures, including those for GPUs, such as Nvidia CUDA or AMD GPUs.

intrinsic("llvm.nvvm.read.ptx.sreg.tid.x")   threadIdxX() u32 @public;
intrinsic("llvm.nvvm.read.ptx.sreg.ctaid.x") blockIdxX()  u32 @public;
intrinsic("llvm.nvvm.read.ptx.sreg.ntid.x")  blockDimX()  u32 @public;
intrinsic("llvm.nvvm.barrier0") syncthreads() void @public;

static mut sdata: array[f32; 256, 3] @linkage("internal") @public;

fn vecAdd(
    a: ptr[f32, 1],
    b: ptr[f32, 1],
    c: ptr[f32, 1],
    n: s32
) void @cuda @public {
    var tid: u32 = blockIdxX() * blockDimX() + threadIdxX();

    if (tid as s32 < n) {
        c[tid] = (deref a[tid]) + (deref b[tid]);
    }
}

If you would like to see more detailed real-world examples of how to use the programming language, you can check out the showcase folder on thrustc.

Thrust Programming Language - Showcase folder

standard-separator

Current Features

  • Full standalone Ahead Of Time (AOT) compilation.
  • Full Just In Time (JIT) compilation via -jit.
  • Control over deeper C compiler code optimizations.
  • Deeper code generation control.
  • Robust static type checking.
  • Standalone x86_64 assembler interoperability.
  • System-V ABI compliant

Future Features

  • Automatically generated types for C headers (CBindgen) through the Clang frontend C & C++ compiler.
  • Quantum code generation, through QIR.
  • Support for quantum behavior emulation with embedded QCOR, or a bytecode runner.

Examples

Compiler

Linux

./thrustc -opt=O3 fibonacci.thrust -start -o fibonacci -end && ./fibonacci

Windows

.\thrustc.exe -opt=O3 fibonacci.thrust -start -o fibonacci.exe -end && .\fibonacci.exe

Package Manager

In the future, there will be a package manager that works exactly like Rust Cargo. Once it is installed in the system path at the root of the project, wherever the Project.toml file is located, it will automate the program's build process.

torio run

Code Example - Hello World

// ******************************************************************************************
//
//   Hello World!
//
// ******************************************************************************************

// Thrust Programming Language - File extensions
// 
// - '.🐦'
// - '.thrust'
//

// External declaration for the C printf function
fn print(fmt: const array[char]) s32 @public @arbitraryArgs @extern("printf") @convention("C");

fn main() s32 @public {

    print("Hello World!");         
    return 0;

}

Case Of Study

The Thrust Programming Language is involved with a research project or is part of a census at the University of Porto (U.Porto) and the Institute for Systems and Computer Engineering, Technology and Science (INESC TEC), related to a PhD Research student.

DISCLAIMER: THIS DOES NOT MEAN THAT Thrust PROGRAMMING LANGUAGE IS OFFICIALLY AFFILIATED WITH THESE INSTITUTIONS.

Background

The responsible team (practically a solo developer) considers it a side, not main, project. We focus on improving both ourselves and our side projects in parallel.

Support

We're looking for contributors for our project! If you're a Spanish speaker and would like to contribute, contact us through our official social media channels. Already know Rust but not LLVM or GCC? Don't worry! We're happy to teach you.

standard-separator

Social Networks

Thrust Programming Language

Always Remember

~ "It takes a long time to make a tool that is simple and beautiful." ~ Bjarne Stroustrup (C++ Programming Language creator)

Pinned Loading

  1. thrustc thrustc Public

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

    Rust 33 4

  2. torio torio Public

    The package manager and compiler-controller for the Thrust Programming Language.

    Rust 3 1

Repositories

Showing 10 of 14 repositories

Top languages

Loading…

Most used topics

Loading…