Gradient is a programming language designed for AI-assisted development.
It combines a typed language, a compiler with structured query surfaces, and a roadmap toward self-hosting so that agents can generate, inspect, verify, and eventually improve the language in the language itself.
Gradient targets four overlapping use cases:
- Agent-assisted coding. Give coding agents a language with explicit effects, contracts, and a machine-readable compiler surface instead of relying on fragile prompt-only loops.
- Compiler-verified automation. Move from generate-compile-fix toward generate-check-verify by making syntax, type expectations, and side effects more explicit.
- Tooling for agent workflows. Expose compiler services, diagnostics, and query APIs that are easier for agents and IDEs to consume than raw terminal text.
- Research on agent-native languages. Explore how tools, authority, effects, contracts, and eventually memory/protocol abstractions can become first-class language concepts.
Most current LLM coding workflows burn tokens and time on avoidable failure loops:
- syntax mistakes
- missing type context
- hidden side effects
- weak tooling interfaces
- repeated compile-fix retries
Gradient is built to reduce that waste through:
| Technique | Why It Matters |
|---|---|
| Grammar-constrained generation | pushes syntax validity earlier in the generation loop |
| Effect tracking | makes side effects explicit instead of implicit |
| Contracts | supports generate-check-verify workflows |
| Structured compiler queries | gives agents machine-readable diagnostics and symbol data |
| Self-hosting roadmap | turns the compiler into a dogfooded agent-facing system |
The Rust host compiler is the stable center of the project today.
Available now:
- native compilation via Cranelift
- static type checking with inference
- algebraic data types and pattern matching
- generics
- modules
- contracts via
@requires/@ensures - effect tracking
- lists, maps, tuples, closures, traits, and actor syntax
- compiler-as-library query APIs
- LSP support
gradient build,run,check,test,fmt,repl, and dependency workflows
Supporting docs:
Gradient is still alpha software.
These areas are real, but not yet production-grade:
- the self-hosted compiler in
compiler/*.gr - WebAssembly support
- LLVM backend completion
- registry-backed package distribution
- refinement types and session types
Public docs should be read with that distinction in mind:
- Cranelift is the working default backend
- WASM exists as an experimental path, not the primary production path
- LLVM is a medium-term engineering option, not the current focus
@requires(n >= 0)
@ensures(result >= 1)
fn factorial(n: Int) -> Int:
if n <= 1:
ret 1
else:
ret n * factorial(n - 1)
Gradient's direction is visible in one small example:
- the function is statically typed
- the intent is declared with contracts
- the compiler can expose this structure to tools and agents
- Rust 1.75+
- optional:
wasm32-unknown-unknowntarget for experimental WASM work
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknowngit clone https://github.com/Ontic-Systems/Gradient.git
cd Gradient/codebase
cargo build --release./target/release/gradient new hello
cd hello
GRADIENT_COMPILER=../target/release/gradient-compiler ../target/release/gradient runcargo build --release --features wasm
./target/release/gradient-compiler hello.gr hello.wasm --backend wasm
wasmtime hello.wasmUse the WASM path as an experiment, not yet as the default deployment story.
fn add(a: Int, b: Int) -> Int:
ret a + b
fn greet(name: String) -> !{IO} ():
print("Hello, " + name)
@requires(b != 0)
@ensures(result * b == a)
fn div_exact(a: Int, b: Int) -> Int:
ret a / b
type Option[T] = Some(T) | None
fn unwrap_or[T](opt: Option[T], default: T) -> T:
match opt:
Some(value): value
None: default
| Area | Status | Notes |
|---|---|---|
| Rust host compiler | Stable core |
primary implementation |
| Cranelift backend | Stable core |
default codegen path |
| Type system | Stable core |
inference, effects, contracts, generics |
| Query API | Stable core |
machine-readable compiler services |
| LSP | Stable core |
editor and agent integration surface |
| Modules and build flow | Stable core |
multi-file project support |
| Area | Status | Notes |
|---|---|---|
| Self-hosted compiler | In progress |
major strategic focus |
| WebAssembly backend | Experimental |
useful path, not yet the default story |
| LLVM backend | Incomplete |
not on the immediate critical path |
| Package registry | Planned |
path dependencies are the practical option today |
| Refinement and session types | Planned |
research-backed, not near-term execution work |
The roadmap has been updated to reflect the current research consensus.
Short version:
- lock the bootstrap parser subset
- implement the first self-hosted parser milestone
- build parser comparison and differential tests early
- finish comptime polish
- continue self-hosted checker / IR / bootstrap work
- revisit LLVM and production WASM after self-hosting pressure drops
- keep advancing the longer-term agent-native language design agenda in parallel
Detailed docs:
Gradient is not trying to be "just another general-purpose language."
The project is aimed at a narrower and more ambitious intersection:
- a language that agents can generate more reliably
- a compiler that agents can query directly
- a workflow that moves verification closer to generation
- a long-term language design program for agent-native software systems
That means the near-term value is practical tooling and compiler behavior.
The long-term value is a language whose semantics are shaped around tools, authority, verification, and machine-assisted development from the start.
Gradient/
├── codebase/ Rust host compiler and toolchain
├── compiler/ Self-hosted Gradient compiler work
├── docs/ Public documentation
├── examples/ Example programs
├── resources/ Grammar and language reference material
└── assets/ Project assets
MIT. See LICENSE.
