Systems programming
with a friendly syntax

A statically-typed, compiled language with C-like manual memory management. No garbage collector, predictable performance, compiles to portable C89.

hello.srs
package main

import "std:fmt"

func main() {
    // Array programming
    a := [4]int{1, 2, 3, 4}
    b := [4]int{10, 20, 30, 40}
    c := a + b
    
    // Inline C for FFI
    #inline `printf("C says: %d\n", ${c[0]});`
    
    fmt.Printf("Hello from Saurus!\n")
}

Features

*p

No Garbage Collection

Complete control over memory with new, make, append, and free. Predictable performance for systems programming.

c89

Portability

Compiles to portable C89 code. Run anywhere you have a C compiler, from embedded devices to supercomputers.

:=

Clean Syntax

Clean, familiar syntax with minimal boilerplate. Type inference, first-class functions, and multiple return values.

[n]

Array Programming

Element-wise operations on arrays, swizzle access (v.x, v.y), and size inference with [_] syntax.

[~]

Collections

Dynamic arrays with list[T], hash maps with map[K]V, and zero-copy slices []T.

#c

C Interop

Embed C with #inline, import with #extern, export with #export. Seamless FFI.

Code Examples

Dynamic Arrays & Slices

package main

import "std:fmt"

func main() {
    // Dynamic array
    nums := make([dynamic]int, 0, 4)
    append(nums, 1, 2, 3)
    
    // Slice (array view)
    view := nums[:2]
    
    for i, v in nums {
        fmt.Printf("%d: %d\n", i, v)
    }
    
    free(nums)
}

Structs & Multiple Returns

package main

import "std:fmt"

struct Point {
    x, y int
}

func divide(a, b int) (int, int) {
    return a / b, a % b
}

func main() {
    q, r := divide(17, 5)
    fmt.Printf("17/5 = %d remainder %d\n", q, r)
    
    p := new(Point)
    p.x, p.y = 10, 20
    free(p)
}

Maps

package main

import "std:fmt"

func main() {
    // Create a map
    scores := make(map[string]int)
    scores["alice"] = 100
    scores["bob"] = 95
    
    for name, score in scores {
        fmt.Printf("%s: %d\n", name, score)
    }
    
    remove(scores, "bob")
    free(scores)
}

Constants with Iota

package main

const (
    Sunday = iota
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
)

const (
    _ = iota
    KB = 1 << (10 * iota)
    MB
    GB
)

func main() {
    // Sunday = 0, Monday = 1, ...
    // KB = 1024, MB = 1048576
}

Installation

Build from Source

git clone --recurse-submodules \
    https://codeberg.org/saurus/saurus.git
cd saurus
make

Run & Compile

# Run directly
./saurus hello.srs

# Compile to executable
./saurus -c -o hello hello.srs

Windows: Use WSL to build. Cross-compile with: CC=x86_64-w64-mingw32-gcc ./saurus -c -o hello.exe hello.srs

VSCode Extension

Official syntax highlighting and language support for Visual Studio Code.

Download Extension