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 is specified for future runtime hot-swap modules.

Repeatable tests

The bootstrap compiler currently runs 13 regression tests. Formal .f.test module support is specified but not implemented yet.

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 and passes 13 regression tests. The self-hosting compiler is written in Foundation itself and has been proven across three generations: compiler builds itself, that binary builds itself again, and the third generation passes its test suite.

Implementation Notes

Some language features are still specified ahead of implementation: float codegen, array/map/tuple literals, field access, match codegen, dynamic load, new instance dispatch, and tuple unpacking.

For AI Agents

Concise LLM view: llms.txt

Full language specification: foundation.md