Sync is an easily embeddable programming language for building robust, scalable software with parallel performance and memory safety.

Embeddable

Sync is lightweight, being embeddable easily into applications using any build system. A simple API is provided, with native support for C, C++, Rust, and Zig. Sync can also be built on all platforms that have a standard C++17 or higher compiler.

Simple

All Sync structs use the C struct memory layout, and no garbage collector is used, allowing you to pass data to and from Sync functions without any translation layers. Sync is deterministic, using move semantics and destructors.

Multithreading

Sync supports running all built code in parallel, without data races and deadlocks. It is well-suited to use all of the processing power available in a CPU.

Safety

Thread safety is memory safety. Sync's ownership model guarantees modern safety at compile-time while also being able to communicate safely with the program it is embedded in.

Flexibility

Sync code is compiled when you want while your host program is running. This allows maximum flexibility in what your program can do.

// Mutable global variable
// Compiler enforces thread safety with the `Owned` modifier
mut counter: Owned i32 = 0;

fn addOne() {
    for i in 0..10000 { // Iterates 0, 1, 2, .. 9999
        // Acquire a read-write (exclusive) lock
        sync mut counter {
            counter += 1;
        }
    }
}

fn addTwo(n: usize) {
    for i in 0..n { // Iterates [0, n)
        // Acquire a read-write (exclusive) lock
        sync mut counter {
            counter += 2;
        }
    }
}

fn main() {
    {
        const t1 = Thread.spawn(addOne);
        const t2 = Thread.spawn(addTwo, 20000);
    }

    // Acquire an read-only (shared) lock
    sync counter {
        print(counter); // 50000
    }
}