跳到正文
DEV Community· Oster·· 1 天前AI 評分27

Oster:以 AI 協作開發、以 Rust 編寫的實驗性程式語言

A programming language written with AI in rust

AI 導讀

Oster 是一款以 Rust 編寫、並在 AI 協作下開發的實驗性程式語言及編譯器,可編譯為可移植的 C11。它旨在結合所有權、借用檢查等靜態安全保障,以及標準 C11 的可移植性,方便編譯至支援 C 編譯器的平台並整合現有 C 程式碼庫。

正文

Oster

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);
}

來源:DEV Community · dev.to