A fast, indentation-based programming language compiling to standalone native machine code via Rust.
Website • Documentation • Getting Started • Changelog • Issues
XE is an expressive, indentation-based programming language built for developers who want the clean readability of Python with the execution speed and standalone binary output of native code.
XE compiles source files to Rust and builds them with rustc and LLVM into standalone native executables.
# Quick look at XE syntax
fun fibonacci(n):
if n <= 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)
fun main():
limit = 10
print("Fibonacci sequence up to", limit)
for i in range(limit + 1):
print(f"fib({i}) = {fibonacci(i)}")
main()
- Native Performance: Compiles to native machine code via Rust; no interpreter.
- Pythonic Syntax and Semantics: Indentation-based blocks, Python-style scoping, shared lists and maps, f-strings, comprehensions, unpacking, conditional expressions, default and keyword arguments,
try/catch,lambda, slicing and+=. - Structs with Methods: Records with default field values and methods; method calls on known structs compile to direct native calls.
- Type Inference: Numbers, text and booleans with known types, including function parameters and return values, compile to native
f64,Stringandbool. - Multi-File Modules: Namespaced imports (
import geometry,geometry.area(...)) andfrom helpers import format_name. - Batteries Included: Built-ins for text, lists, maps, math, files and command-line arguments.
- Rich Diagnostics: Compiler and runtime errors show the file, line and source line.
- Built-in CLI: One tool for running (with a build cache), compiling, installing and self-updating.
curl -fsSL https://xe-lang.vercel.app/install.sh | bashTo install to a custom directory:
XE_INSTALL_DIR="$HOME/bin" curl -fsSL https://xe-lang.vercel.app/install.sh | bashPrerequisites: Rust toolchain (rustc & cargo 1.70+).
git clone https://github.com/V8V88V8V88/XE.git
cd XE
cargo build --release
# Install binary to ~/.local/bin
./target/release/xe install| Command | Description |
|---|---|
xe run <file.xe> |
Compile and execute an XE program immediately |
xe compile <file.xe> -o <binary> |
Build an optimized standalone native binary |
xe compile <file.xe> |
Emit generated Rust source code to stdout |
xe update |
Check for and install the latest compiler release |
xe --version |
Display compiler version |
# Run a single file
xe run examples/hello.xe
# Compile to an optimized binary
xe compile examples/adventure.xe -o adventure
./adventure
# Run a multi-module program
xe run examples/modules/main.xegraph LR
Source[".xe Source"] --> Lexer["Lexer\n(Tokens)"]
Lexer --> Parser["Parser\n(AST)"]
Parser --> Semantic["Semantic Analyzer\n(Type & Scope Checking)"]
Semantic --> IR["Typed IR\n(Hybrid Inference)"]
IR --> Codegen["Rust Code Generator"]
Codegen --> Rustc["rustc Backend\n(Native Machine Code)"]
Rustc --> Binary["Standalone Binary"]
- Lexer (
lexer.rs): Scans tokens, indentation levels, and source spans. - Parser (
parser.rs): Validates grammar and builds the Abstract Syntax Tree (AST). - Compiler Linker (
compiler.rs): Resolves module dependency graphs and resolves names across modules. - Semantic Analyzer (
semantic.rs): Checks names, scopes and types, and infers native types for function parameters and return values. - Codegen (
codegen.rs): Generates Rust code on top of the runtime inruntime/prelude.rs. Built-in functions are defined once inbuiltins.rs. - Backend (
rustc): Compiles generated Rust directly to native platform binaries.
name = "XE" # Text (String)
version = 0.1 # Number (f64)
is_fast = true # Boolean (bool)
items = [1, 2, 3, 4] # List (shared, like Python)
user = {"name": "Ada"} # Map
nothing = none # None
score = 85
count = 3
# If / Elif / Else
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
else:
print("Grade: C")
# For Loops (Lists & Strings)
for item in [10, 20, 30]:
print(item)
for ch in "XE":
print(ch)
# While & Repeat Loops
while count > 0:
count = count - 1
repeat 5 times:
print("Hello!")
# File: math_utils.xe
fun square(x):
return x * x
# File: main.xe
from math_utils import square
print("5 squared is", square(5))
struct Point:
x
y = 0
fun scaled(self, k = 2):
return Point(self.x * k, self.y * k)
p = Point(3, y = 4).scaled()
print(f"p = ({p.x}, {p.y})")
squares = [n * n for n in range(5) if n > 0]
low, high = min(squares), max(squares)
print("big" if high > 10 else "small", low, high)
for i, word in enumerate(["xe", "lang"]):
print(i, word.upper())
A reproducible benchmark comparing XE with CPython on a recursive Fibonacci workload:
python3 examples/benchmark.pyOn a recursive fib(32), XE runs about 15 times faster than CPython (0.013 s vs 0.21 s on the author's machine), because the inferred native types turn it into plain f64 Rust code.
# Run the full automated test suite
cargo test
# Run linter checks
cargo clippy --all-targets --all-featuresTo view or build the documentation locally:
cd docs
npm install
npm run docs:dev- Multi-file module dependency resolver & linker
- Type inference with native types for parameters and return values
- Python-style scoping,
global, and shared values - Compiler and runtime errors with source locations
- First-class functions and lambda expressions
- Standard library: text, lists, maps, math, files, arguments
- User-defined structs / records
-
try/catcherror handling - f-strings, comprehensions, unpacking, default and keyword arguments
- Struct methods
- Language Server Protocol (LSP) and VS Code Extension
This project is licensed under the GPL-3.0-or-later license. See the LICENSE file for details.