Skip to content

Ontic-Systems/Gradient

Repository files navigation

Gradient

An agent-native programming language and compiler stack.


Status Language License Backend Stage


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.

What Gradient Is For

Gradient targets four overlapping use cases:

  1. 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.
  2. Compiler-verified automation. Move from generate-compile-fix toward generate-check-verify by making syntax, type expectations, and side effects more explicit.
  3. Tooling for agent workflows. Expose compiler services, diagnostics, and query APIs that are easier for agents and IDEs to consume than raw terminal text.
  4. Research on agent-native languages. Explore how tools, authority, effects, contracts, and eventually memory/protocol abstractions can become first-class language concepts.

Why Gradient Exists

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

What Works Today

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:

What Is Still Experimental

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

Quick Example

@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

Quick Start

Prerequisites

  • Rust 1.75+
  • optional: wasm32-unknown-unknown target for experimental WASM work
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown

Build

git clone https://github.com/Ontic-Systems/Gradient.git
cd Gradient/codebase
cargo build --release

Create and run a project

./target/release/gradient new hello
cd hello
GRADIENT_COMPILER=../target/release/gradient-compiler ../target/release/gradient run

Experimental WASM path

cargo build --release --features wasm
./target/release/gradient-compiler hello.gr hello.wasm --backend wasm
wasmtime hello.wasm

Use the WASM path as an experiment, not yet as the default deployment story.

Language Highlights

Effects are explicit

fn add(a: Int, b: Int) -> Int:
    ret a + b

fn greet(name: String) -> !{IO} ():
    print("Hello, " + name)

Contracts are part of the surface language

@requires(b != 0)
@ensures(result * b == a)
fn div_exact(a: Int, b: Int) -> Int:
    ret a / b

Generics and algebraic data types are built in

type Option[T] = Some(T) | None

fn unwrap_or[T](opt: Option[T], default: T) -> T:
    match opt:
        Some(value): value
        None: default

Project Status

Stable core

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

Experimental / in progress

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

Roadmap

The roadmap has been updated to reflect the current research consensus.

Short version:

  1. lock the bootstrap parser subset
  2. implement the first self-hosted parser milestone
  3. build parser comparison and differential tests early
  4. finish comptime polish
  5. continue self-hosted checker / IR / bootstrap work
  6. revisit LLVM and production WASM after self-hosting pressure drops
  7. keep advancing the longer-term agent-native language design agenda in parallel

Detailed docs:

Intended Positioning

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.

Repository Layout

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

License

MIT. See LICENSE.

Built for agents. Grounded in the compiler.

About

The world's first programming language designed for autonomous AI agents. Token-efficient, systems-capable, agentic-first.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages