Skip to main content

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

examples/runnable/hello.ail
-- 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

examples/runnable/recursion_factorial.ail
-- 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

For Human Developers

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 List for 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, apply commands
  • Shared Semantic State (v0.6.0) - Multi-agent coordination via shared memory

See our Vision for the full roadmap and Roadmap for detailed plans.

Documentation Structure

  • Examples - Interactive code examples with explanations
  • Guides - Tutorials and how-to guides
  • Reference - Language specification and API docs
  • Playground - Try AILANG in your browser

Contributing

AILANG is open source and welcomes contributions! Visit our GitHub repository to:

  • Report issues
  • Submit pull requests
  • Join design discussions
  • Review the roadmap

Design Philosophy

AILANG is built on several key principles:

  1. Explicit Over Implicit: All effects and dependencies are visible in types
  2. Debuggability by Construction: Structured traces and effect boundaries make errors easy to localize
  3. AI-Optimized: Constrained syntax and explicit effects narrow the search space for valid code
  4. Deterministic: Same input always produces same output, enabling replay and caching
  5. Traceable: Effect calls logged with typed inputs/outputs for structured debugging

Read the full Vision to understand why AILANG is designed for the AI era.

Resources


AILANG is an experimental language under active development. APIs and syntax may change.