AILANG: AI-First Programming Language
Welcome to the official documentation for AILANG, an experimental programming language designed from the ground up for AI-assisted software development.
New to AILANG? Read our Vision to understand why AILANG exists and what makes it different from other programming languages.
What is AILANG?
AILANG is a pure functional programming language designed for AI-assisted development. Explicit effects, structured traces, and deterministic execution make AI-generated code easier to debug and verify.
Key features:
- Pure Functional Core: Deterministic evaluation, referentially transparent
- Algebraic Effects: Side effects declared in types (
! {IO, FS, Net})—constrains what code can do - Structured Traces: Effect calls logged with typed inputs/outputs for debugging
- Pattern Matching: ADTs with exhaustiveness checking catch invalid states at compile time
- Inline Tests: Machine-readable specs that travel with code
- Go Codegen: Compile to native performance with full type safety
Quick Example
Hello World
-- hello.ail - Simple hello world program
module examples/runnable/hello
-- Entry module with exported main function
-- Gets print prelude automatically (no import needed)
export func main() -> () ! {IO} =
print("Hello, AILANG!")
Run with: ailang run --caps IO --entry main examples/runnable/hello.ail
Recursive Factorial
-- recursion_factorial.ail
-- Demonstrates simple recursive function with LetRec
-- Status: ✅ Working (M-R4 recursion support)
module examples/runnable/recursion_factorial
import std/io (println)
-- Classic factorial using recursion
pure func factorial(n: int) -> int
tests [
(0, 1),
(1, 1),
(5, 120),
(10, 3628800),
(12, 479001600)
]
{
if n <= 1 then 1 else n * factorial(n - 1)
}
-- Tail-recursive factorial with accumulator
pure func factorialTail(n: int, acc: int) -> int
tests [
((0, 1), 1),
((1, 1), 1),
((5, 1), 120),
((10, 1), 3628800),
((12, 1), 479001600)
]
{
if n <= 1 then acc else factorialTail(n - 1, n * acc)
}
export func main() -> () ! {IO} {
let result1 = factorial(5);
let result2 = factorialTail(10, 1);
println("factorial(5) = " ++ show(result1));
println("factorialTail(10, 1) = " ++ show(result2))
}
Run with: ailang run --entry factorial examples/runnable/recursion_factorial.ail
Getting Started
For AI Agents
-
AI Agent Integration Guide Quick start for AI coding agents (Claude, GPT, Gemini)
-
Teaching Prompt (Current: v0.5.2) Complete AILANG syntax guide for AI models
For Human Developers
-
Installation Guide Install AILANG and run your first program
-
Language Tutorial Learn the basics of AILANG programming
-
Language Reference Complete syntax and semantics reference
-
REPL Commands Interactive development with the AILANG REPL
Current Status:
AILANG is the latest stable release. Check the implementation status for complete details.
Core Features
- Recursion - Self-recursion, mutual recursion, with stack overflow protection
- Block Expressions - Multi-statement blocks with proper scoping
- Records - Record literals, field access, subsumption
- Type System - Hindley-Milner inference with type classes (Num, Eq, Ord, Show)
- Pattern Matching - Constructors, tuples, lists, wildcards, guards
- Module System - Cross-module imports, entrypoint execution
- Effect System - IO, FS, Clock, Net with capability-based security
- Clock Effect: Monotonic time, sleep, deterministic mode
- Net Effect: HTTP GET/POST with DNS rebinding prevention, IP blocking
- Inline Tests (NEW v0.4.5) - Test pure functions directly in code,
ailang test - REPL - Full type checking, command history, tab completion
- Lambda Calculus - First-class functions, closures, currying
Recent Additions (v0.5.x)
- Go Codegen - Compile AILANG to typed Go code (
ailang compile --emit-go) - Import Aliasing -
import std/list as Listfor cleaner qualified access - Array Support - Fixed-size arrays with
Array[T]type and#[...]literals - Agent Messaging - Unified messaging system via
ailang messages
Roadmap
- Execution Profiles (v0.6.0) - Formal SimProfile, ServiceProfile, CliProfile with validation
- Deterministic Tooling (v0.7.0) -
normalize,suggest-imports,applycommands - Shared Semantic State (v0.6.0) - Multi-agent coordination via shared memory
See our Vision for the full roadmap and Roadmap for detailed plans.