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.
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
No Garbage Collection
Complete control over memory with new, make, append, and free. Predictable performance for systems programming.
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.
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 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(list[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"
type Point struct {
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
}
Any Type & Type Switches
package main
import "std:fmt"
func describe(a any) {
switch v in a {
case int:
fmt.Printf("integer: %d\n", v)
case string:
fmt.Printf("string: %s\n", v)
case bool:
fmt.Printf("bool: %t\n", v)
case:
fmt.Printf("unknown type\n")
}
}
func main() {
describe(42)
describe("hello")
describe(true)
}
Defer & Resource Cleanup
package main
import "std:fmt"
type Buffer struct {
data *byte
size int
}
func process() {
buf := new(Buffer)
defer free(buf)
items := make(list[int], 0, 8)
defer free(items)
append(items, 1, 2, 3)
fmt.Printf("items: %d\n", len(items))
// free runs in LIFO order on return
}
func main() {
process()
}
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