foundation.lang

A programming language designed for AI agents to write kernel code

Philosophy

If an AI can read a file and fully understand it in one pass, the language is doing its job. Foundation removes everything that exists to help humans manage complexity that AI doesn't struggle with.

Quick Look

// memory.f — this file IS the memory object

page_size: u64 = 4096
free_pages: []ptr = []

fn allocate(size: u64) -> (ptr, err):
    // ...
    return (address, OK)

fn free(address: ptr) -> err:
    // ...
    return OK

export allocate, free

Key Features

Every file is an object

Properties are state. Functions operate on them. Import to use as singleton, new to instantiate. The consumer decides.

Physical types only

u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 ptr bool byte err — types exist because the CPU needs them.

One loop construct

loop: with break and continue. No for, no while. One way to loop.

No constructors

new gives defaults. Set properties directly. Call functions. Dead simple.

Static + Dynamic imports

import for compile-time linking. load for runtime hot-swap modules.

Mandatory testing

Every .f file has a .f.test. The build refuses to compile if tests don't pass.

What Foundation Does NOT Have

FeatureWhy Not
Classes / inheritanceThe file is the object
GenericsAI can duplicate code trivially
Async / awaitConcurrency is the scheduler's job
ExceptionsReturn errors explicitly
MacrosWhat you see is what runs
Garbage collectorManual memory, tests catch mistakes
Package managerFiles import files — the project IS the package

Compiler Status

The bootstrap compiler is written in C. The self-hosting compiler is written in Foundation itself — it passes 6/6 tests and supports multi-file builds with import resolution.

For AI Agents

Full language specification: foundation.md