Xu programming language: native self-hosting compiler, toolchain and runtime
See the code
Go-like Concurrency Meets C/Rust Zero-GC Performance
A compile-time memory-safe systems language engineered for high-throughput, low-latency, and modern applications.
English | 简体中文
🌐 Online Playground (No Install) • ⚡ 47-Task Benchmark Dashboard • 🚀 30s Quick Start • 📦 Download Installers
No complex boilerplate. No convoluted lifetime annotation gymnastics. Experience Xu's clean modern syntax in 15 lines of code:
@main
#errors
// Symbolic flow control: `<<` returns, `>>` throws; no nested Result/unwrap boilerplate
fn fetch_metric(task string) int {
if task.len == 0 { >> errors.new("empty task name") }
<< task.len * 42
}
fn worker(task string, ch chan int) {
val := fetch_metric(task) or (err) { << } // Mandatory safe local handling without `if err != nil`
ch <- val // Type-safe channel messaging
}
fn main() int {
ch := chan int{cap: 2}
xu worker("latency", ch) // Native `xu` keyword spawns lightweight coroutine
xu worker("memory", ch)
println(<-ch + <-ch) // Fan-in channel aggregation
<< 0 // Deterministic teardown, zero GC pauses, static AOT native build
}
Why Developers Love It:
- Symbolic Flow Control:
<<returns,>>throws,<<<exits. Goodbye verbose legacy keywords.- Ergonomic Error Flow: Handled at the call site with
or (err) { ... }. Eliminates screen-clutteringif err != niland catastrophic runtimeunwrap()panics.- Native Lightweight Concurrency:
xu worker()coroutines +chanchannels provide effortless Go-like concurrency.- Compile-time Static Safety: Tracked via ownership & borrow inference. Zero garbage collection (Zero-GC), zero pauses, and ultra-lean deterministic memory consumption.
As software engineers building high-performance systems and services, we are constantly forced to choose between flawed trade-offs:
'a, 'b) and complex type gymnastics drastically slow down development speed.if err != nil. Rust wraps types inside multiple Result<T, E> / Option layers.>> combined with mandatory or (err) { ... }, providing lightweight, clean, and safe error propagation.xu fmt), documentation generator (xu doc), and self-rendered GUI setup wizards—is built right in.| Key Dimension | C / C++ | Go | Rust | Xu |
|---|---|---|---|---|
| Memory Management | Manual malloc/free (Leaks & dangling pointers) | Runtime GC (STW latency pauses & memory bloat) | Compile-time ownership (Explicit lifetime 'a annotations) | Compile-time ownership (Zero-GC / Deterministic drops) |
| Runtime Overhead | Zero-cost abstractions | Heavy (GC engine + scheduler runtime) | Zero-cost abstractions | Zero-cost (No GC engine / Pure native machine code) |
| Cognitive Load | Vulnerable to UB & race conditions | Simple, but nil panics persist | Steep learning curve (Borrow checker fights) | Minimal (No lifetime annotations / Clean symbolic flow) |
| Concurrency Model | OS threads / External libraries | CSP coroutines (go) + channels (chan) | Threads / Async runtimes (Function coloring) | Native lightweight coroutines (xu) + typed chan |
| Error Handling | Error codes / Exceptions (Implicit) | if err != nil (Cluttered boilerplate) | Result<T, E> + ? operator | Symbolic flow: >> throw + or mandatory handling |
| Flow Control | return / break / continue | return / break / continue | return / Tail expressions | Symbolic flow: << return / >> throw / <- break |
| Toolchain Cohesion | Fragmented (CMake/Make/Conan) | Integrated out-of-the-box | Integrated (Cargo) | Single-binary loop (Built-in build/test/fmt/doc) |
| Cross-Platform Setup | Complex toolchain & linker dependencies | Official installer / manual PATH config | Requires rustup & external network scripts | Standalone GUI Setup wizards / One-click setup |
Jump directly into the xulang.org Online Playground. Powered by a client-side WebAssembly build of Xu, you can test and experiment with full language features instantly.
Xu provides standalone installers with embedded compilers and standard library sources that automatically register persistent system environment variables:
macOS / Linux (One command in terminal):
# Detects architecture, downloads, and configures environment automatically
curl -fsSL https://xulang.org/install.sh | bash
Or download standalone binaries from Releases:
chmod +x xu-setup-linux-x64 && ./xu-setup-linux-x64 -y
Windows (GUI Wizard or PowerShell):
xu-setup-windows-x64.exe from Releases and double-click to run the zero-dependency self-rendered wizard.irm https://xulang.org/install.ps1 | iex
Open a new terminal and type
xu --versionto run from anywhere.
# 1. Create source file
cat << 'EOF' > main.xu
@main
fn main() int {
println("Hello, World! Welcome to Xu.")
<< 0
}
EOF
# 2. Run immediately
xu run main.xu
# 3. Compile ahead-of-time to an optimized native binary
xu build main.xu -o myapp
./myapp
| Command | Description |
|---|---|
xu run <file.xu> | Rapid compilation and in-memory execution |
xu build <file.xu> -o <bin> | AOT compile to an optimized, standalone native binary |
xu build --target wasm32 <file.xu> | Cross-compile directly to WebAssembly |
xu test <file.xu> | Execute integrated unit tests and assertion suites |
xu fmt <file.xu> -w | Automatically format code according to official guidelines |
xu doc <dir> --public | Extract doc comments and generate clean API references |
xu doctor | Diagnostics tool checking native C linkers and SDK health |
Driven by continuous active iteration, Xu is rapidly evolving. Here is our current status and roadmap:
Gen2 == Gen3)xu keyword scheduling paired with typed chan communication<< return, >> throw, and mandatory local or (err) { ... } guardsXu is an open-source, forward-looking systems programming language. If you believe in Zero-GC extreme performance combined with ergonomic modern syntax, we invite you to join us!
The Xu programming language is open source under the MIT License.
Xu programming language: native self-hosting compiler, toolchain and runtime
See the code
Go-like Concurrency Meets C/Rust Zero-GC Performance
A compile-time memory-safe systems language engineered for high-throughput, low-latency, and modern applications.
English | 简体中文
🌐 Online Playground (No Install) • ⚡ 47-Task Benchmark Dashboard • 🚀 30s Quick Start • 📦 Download Installers
No complex boilerplate. No convoluted lifetime annotation gymnastics. Experience Xu's clean modern syntax in 15 lines of code:
@main
#errors
// Symbolic flow control: `<<` returns, `>>` throws; no nested Result/unwrap boilerplate
fn fetch_metric(task string) int {
if task.len == 0 { >> errors.new("empty task name") }
<< task.len * 42
}
fn worker(task string, ch chan int) {
val := fetch_metric(task) or (err) { << } // Mandatory safe local handling without `if err != nil`
ch <- val // Type-safe channel messaging
}
fn main() int {
ch := chan int{cap: 2}
xu worker("latency", ch) // Native `xu` keyword spawns lightweight coroutine
xu worker("memory", ch)
println(<-ch + <-ch) // Fan-in channel aggregation
<< 0 // Deterministic teardown, zero GC pauses, static AOT native build
}
Why Developers Love It:
- Symbolic Flow Control:
<<returns,>>throws,<<<exits. Goodbye verbose legacy keywords.- Ergonomic Error Flow: Handled at the call site with
or (err) { ... }. Eliminates screen-clutteringif err != niland catastrophic runtimeunwrap()panics.- Native Lightweight Concurrency:
xu worker()coroutines +chanchannels provide effortless Go-like concurrency.- Compile-time Static Safety: Tracked via ownership & borrow inference. Zero garbage collection (Zero-GC), zero pauses, and ultra-lean deterministic memory consumption.
As software engineers building high-performance systems and services, we are constantly forced to choose between flawed trade-offs:
'a, 'b) and complex type gymnastics drastically slow down development speed.if err != nil. Rust wraps types inside multiple Result<T, E> / Option layers.>> combined with mandatory or (err) { ... }, providing lightweight, clean, and safe error propagation.xu fmt), documentation generator (xu doc), and self-rendered GUI setup wizards—is built right in.| Key Dimension | C / C++ | Go | Rust | Xu |
|---|---|---|---|---|
| Memory Management | Manual malloc/free (Leaks & dangling pointers) | Runtime GC (STW latency pauses & memory bloat) | Compile-time ownership (Explicit lifetime 'a annotations) | Compile-time ownership (Zero-GC / Deterministic drops) |
| Runtime Overhead | Zero-cost abstractions | Heavy (GC engine + scheduler runtime) | Zero-cost abstractions | Zero-cost (No GC engine / Pure native machine code) |
| Cognitive Load | Vulnerable to UB & race conditions | Simple, but nil panics persist | Steep learning curve (Borrow checker fights) | Minimal (No lifetime annotations / Clean symbolic flow) |
| Concurrency Model | OS threads / External libraries | CSP coroutines (go) + channels (chan) | Threads / Async runtimes (Function coloring) | Native lightweight coroutines (xu) + typed chan |
| Error Handling | Error codes / Exceptions (Implicit) | if err != nil (Cluttered boilerplate) | Result<T, E> + ? operator | Symbolic flow: >> throw + or mandatory handling |
| Flow Control | return / break / continue | return / break / continue | return / Tail expressions | Symbolic flow: << return / >> throw / <- break |
| Toolchain Cohesion | Fragmented (CMake/Make/Conan) | Integrated out-of-the-box | Integrated (Cargo) | Single-binary loop (Built-in build/test/fmt/doc) |
| Cross-Platform Setup | Complex toolchain & linker dependencies | Official installer / manual PATH config | Requires rustup & external network scripts | Standalone GUI Setup wizards / One-click setup |
Jump directly into the xulang.org Online Playground. Powered by a client-side WebAssembly build of Xu, you can test and experiment with full language features instantly.
Xu provides standalone installers with embedded compilers and standard library sources that automatically register persistent system environment variables:
macOS / Linux (One command in terminal):
# Detects architecture, downloads, and configures environment automatically
curl -fsSL https://xulang.org/install.sh | bash
Or download standalone binaries from Releases:
chmod +x xu-setup-linux-x64 && ./xu-setup-linux-x64 -y
Windows (GUI Wizard or PowerShell):
xu-setup-windows-x64.exe from Releases and double-click to run the zero-dependency self-rendered wizard.irm https://xulang.org/install.ps1 | iex
Open a new terminal and type
xu --versionto run from anywhere.
# 1. Create source file
cat << 'EOF' > main.xu
@main
fn main() int {
println("Hello, World! Welcome to Xu.")
<< 0
}
EOF
# 2. Run immediately
xu run main.xu
# 3. Compile ahead-of-time to an optimized native binary
xu build main.xu -o myapp
./myapp
| Command | Description |
|---|---|
xu run <file.xu> | Rapid compilation and in-memory execution |
xu build <file.xu> -o <bin> | AOT compile to an optimized, standalone native binary |
xu build --target wasm32 <file.xu> | Cross-compile directly to WebAssembly |
xu test <file.xu> | Execute integrated unit tests and assertion suites |
xu fmt <file.xu> -w | Automatically format code according to official guidelines |
xu doc <dir> --public | Extract doc comments and generate clean API references |
xu doctor | Diagnostics tool checking native C linkers and SDK health |
Driven by continuous active iteration, Xu is rapidly evolving. Here is our current status and roadmap:
Gen2 == Gen3)xu keyword scheduling paired with typed chan communication<< return, >> throw, and mandatory local or (err) { ... } guardsXu is an open-source, forward-looking systems programming language. If you believe in Zero-GC extreme performance combined with ergonomic modern syntax, we invite you to join us!
The Xu programming language is open source under the MIT License.