Getting Started

Run your first Sanguis program

Prerequisites

Windows 10 or later with Rust installed. A Vulkan-capable GPU is optional: with one, programs press into the grid and settle on the GPU. Without one, everything still runs on the CPU. Vulkan drivers come with your GPU drivers; nothing extra to install.

Installation

Clone and build:

git clone https://github.com/VolkanaDEV/sanguis.git
cd sanguis
cargo build

The build produces the language toolchain: sanguis.exe. The compiler and VM are written in Sanguis itself (lib/compiler.sanguis); Rust only bootstraps them.

First run compiles the compiler. The toolchain hosts its own compiler written in Sanguis. The first bleed takes a few extra seconds while the bootstrap runs; after that it is fast.

The Pipeline

Two commands cover the whole toolchain. Write .sanguis, compile it, run it:

target\debug\sanguis.exe bleed my_program.sanguis -o my_program.bc
target\debug\sanguis.exe ad --target vulkan my_program.bc

bleed compiles source into BloodCode, the portable artifact. ad presses that artifact into the wiring grid and settles it on your GPU. The intermediate file is a text file you can open and read.

Hello World

Create hello.sanguis:

circuit hello;

cell main() -> float {
    print(99.0);
    emit 0.0;
}

Run it:

target\debug\sanguis.exe drip hello.sanguis

Output:

99.0

circuit declares the program body. cell declares a function. print writes to the screen. emit returns the circuit's result. This source was compiled by the Sanguis-written compiler, which is why the language can host itself.

Arithmetic

circuit add_test;

cell main() -> float {
    let a = 1.0;
    let b = 2.0;
    let c = a + b;
    print(c);
    emit 0.0;
}

Output:

3.0

Four operators. +, -, *, /. Division by zero returns 0.0. Evaluated left to right. Operands can be numbers, variables, or builtin results.