C

Safer C.
No rewrite required.

Drop into any codebase today. Your existing C compiles unchanged —
Prism adds defer, orelse, and zero-initialization on top.

CC=prism make
tests
3,136
lines
7k
deps
0
defer

Cleanup that can't be forgotten.

Bound to scope, not to every exit path. Runs in reverse order at scope end — whether you return early, fall through, or hit an error branch.

−18lines avg
3bug classes closed
Before
FILE *f = fopen(path, "r");
if (!f) return -1;

int r = parse(f);
if (r < 0) {
    fclose(f); // easy to forget
    return -1;
}

fclose(f);
return r;
After
FILE *f = fopen(path, "r")
    orelse return -1;
defer fclose(f);

return parse(f);
Before
char *buf = malloc(n);
if (buf == NULL) {
    log_error("OOM");
    return -1;
}
// ... 20 more lines
After
char *buf = malloc(n)
    orelse return -1;
orelse

Inline error handling without the noise.

Checks for NULL or negative return values inline. No nested if-blocks, no repeated cleanup calls, no diverging error paths.

−12lines avg
2bug classes closed
zero-init

No garbage values. Ever.

Every local variable and struct field is automatically zeroed at declaration. The class of bugs from uninitialized memory is simply gone.

less undefined behavior
1bug class closed
Before
typedef struct {
    int width;
    int height;
    int flags; // garbage
} Config;

Config cfg; // uninitialized
if (cfg.flags & VERBOSE) {
    // undefined behavior
}
After
typedef struct {
    int width;
    int height;
    int flags;
} Config;

Config cfg; // zeroed automatically
if (cfg.flags & VERBOSE) {
    // always safe — flags == 0
}
C (compiles fine)
int x = 10;

{
    int x = 20; // silently shadows outer x
    process(x); // uses 20, not 10
}

// gcc/clang: no warning by default
Prism (compile error)
int x = 10;

{
    int x = 20;
    // error: 'x' shadows outer variable
    // declared at line 1.
    // Rename or use outer 'x' directly.
}
safety

Patterns C allows.
Prism doesn't.

Variable shadowing, signed overflow, implicit void* casts — legal C that's almost always a bug. Prism makes them compile errors, not surprises in production.

3bug classes closed
0runtime overhead

Verified against OpenSSL, SQLite, Bash, Curl, GNU Coreutils, and Make — unmodified source.

View Prism on GitHub