r/Compilers • • 7d ago

I built Oster with AI – a memory-safe language with NLL borrow checking that compiles to portable C11

Hey everyone,

I’ve been working with AI on Oster, an experimental programming language and compiler written in Rust that compiles down to portable C11.

Why Oster?

The main goal is to combine modern static safety guarantees (ownership, non-lexical lifetimes / borrow checking, escape analysis, exhaustive pattern matching) with the ubiquity and zero-runtime portability of standard C11 — making it easy to target anything with a C compiler and integrate seamlessly with existing C codebases.

My repo:

https://github.com/kapimati/Oster

What it looks like

Here is a small snippet in Oster:

extern fn puts(s: str) -> i32;

enum Result { Err(str), Ok(i32) }

fn checked_div(a: i32, b: i32) -> Result {

if b == 0 { return Result::Err("division by zero"); }

return Result::Ok(a / b);

}

fn sum_divs() -> Result {

mut let total = 0;

for d in \[2, 4, 5\] {

total += checked_div(100, d)?;

}

return Result::Ok(total);

}

0 Upvotes

3 comments sorted by

1

u/Discordbothost 6d ago

What should checked_div return for -2147483648 divided by -1? The quotient won't fit in i32. That'd be a useful second test alongside division by zero.

1

u/Ill-Froyo-2461 6d ago

Good catch — i32::MIN / -1 (-2147483648 / -1) overflows i32 and is also UB in C11 (and triggers SIGFPE on x86 just like division by zero).

In a proper checked_div, that should return Result::Err("integer overflow") (or a dedicated overflow error variant) right alongside the b == 0 check:

if a == -2147483648 && b == -1 { return Result::Err("overflow"); }

I kept the snippet in the post minimal just to show the ? + tagged-union codegen, but handling signed overflow in C-targeting backends is definitely something I want to get right (either via checked builtins or explicit guards). Thanks for pointing that out!

1

u/LegitMoth 3d ago

you know the field is dead when tom pearl himself is vibecoding compilers