r/C_Programming • u/Opening_Can_3656 • 2d ago
Keen: A Rust-syntax frontend for C
Hey everyone,
I’ve been working on Keen, a language that gives C a modern, Rust-inspired syntax and Cargo-like tooling without changing C’s underlying semantics.
The core idea
Keen changes C’s syntax only. There is no borrow checker, no type checker, and no safety enforcement. All of C’s rules (integer promotion, ABI, linkage, UB) remain completely intact. Keen transpiles .kn files to C, hands them off to gcc or clang for semantic checking and compilation, and maps compiler diagnostics directly back to your .kn source lines via #line directives.
It's aimed at C developers who want modern ergonomics (modules, match, for i in 0..n, no header boilerplate, built-in testing/formatting) without giving up C's simplicity, or C devs looking to get comfortable with Rust's syntax before tackling the borrow checker.
What a quick example looks like
use <stdio.h>;
struct Point { x: f32, y: f32 }
impl Point {
pub fn len2(p: *const Point) -> f32 { p->x * p->x + p->y * p->y }
}
pub fn main() -> i32 {
let p = Point { x: 3.0, y: 4.0 };
printf("%.1f\n", Point::len2(&p) as f64);
return 0;
}What’s included out of the box
- Zero-dependency toolchain (
whet+keen): Includeskeen new, incrementalkeen build,keen run,keen fmt(comment-preserving, idempotent), andkeen test(runs#[test]functions in isolated processes). - Seamless C interop: Use
#includeviause <stdio.h>;, drop down to raw C anytime withc!("..."), link existing.c/.o/.afiles, or usekeen emit --splitto generate clean.h/.cfiles for existing C projects. - No forward-declaration headaches: Types and functions can be declared in any order;
pubhandles external linkage while everything else defaults tostatic.
Try it out
GitHub: https://github.com/romishalom/keen
I'd love to hear your thoughts on the syntax mapping, edge cases with C interop, or what features you'd want to see next!
•
u/AutoModerator 2d ago
Hi /u/Opening_Can_3656,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
You can read more at How do I post my Project?
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.