stacksjs/ion
The speed of Zig. The safety of Rust. The joy of TypeScript.
The speed of Zig. The safety of Rust. The joy of TypeScript.
A systems & application language that doesn't compromise: blazing compile times, memory safety without ceremony, and APIs that spark joy.
๐ง Active Development
Ion is currently in the foundation phase with a working compiler infrastructure and core packages.
Follow Progress: Watch this repo โข Discussions โข Roadmap
Modern systems languages force impossible choices:
Ion refuses to choose. We're building a language that delivers:
import std/http { Server }
import std/database { Connection }
fn main() {
let server = Server.bind(":3000")
let db = Connection.open("app.db")
server.get("/", fn(req) {
return "Hello from Ion!"
})
server.get("/users", fn(req) -> async Response {
let users = await db.query("SELECT * FROM users")
return Response.json(users)
})
server.get("/user/:id", fn(req) -> async Response {
let user = await fetch_user(db, req.param("id"))
return Response.json(user)
})
print("Server running on http://localhost:3000")
server.listen()
}
fn fetch_user(db: &Connection, id: string) -> async Result<User> {
let stmt = db.prepare("SELECT * FROM users WHERE id = ?")
stmt.bind(1, id)
return stmt.execute().first()
}
struct User {
id: i64
name: string
email: string
}
Key Features:
# Clone repository
git clone https://github.com/stacksjs/ion.git
cd ion
# Build compiler
zig build
# Run tests (200+ tests)
zig build test
# Run examples
zig build examples
# Run the HTTP server example
zig build example-router
# Run the database example
zig build example-database
# Run the queue system example
zig build example-queue
# Install Zig
curl -L https://ziglang.org/download/0.15.0/zig-macos-aarch64-0.15.0.tar.xz | tar xJ
# On macOS with Homebrew
brew install zig sqlite3
# On Ubuntu/Debian
sudo apt install zig libsqlite3-dev
# On Arch Linux
sudo pacman -S zig sqlite
Ion is built as a modular monorepo with specialized packages:
packages/
โโโ lexer/ # Tokenization and scanning
โโโ parser/ # AST generation from tokens
โโโ ast/ # Abstract Syntax Tree structures
โโโ types/ # Type system and inference
โโโ diagnostics/ # Error reporting with color output
โโโ interpreter/ # Direct code execution
โโโ codegen/ # Native x64 code generation
โโโ formatter/ # Code formatting
โโโ lsp/ # Language Server Protocol
โโโ pkg/ # Package manager
โโโ testing/ # Modern test framework (snapshots, mocks, benchmarks)
packages/
โโโ stdlib/ # Core standard library
โ โโโ http_router # HTTP server with routing
โ โโโ zyte # Desktop app integration
โโโ database/ # SQL database access (SQLite)
โโโ queue/ # Background job processing
โโโ async/ # Async runtime
โโโ build/ # Build system
โโโ cache/ # Caching utilities
โโโ tools/ # Development tools
packages/
โโโ comptime/ # Compile-time execution
โโโ generics/ # Generic type system
โโโ macros/ # Macro system
โโโ modules/ # Module system
โโโ patterns/ # Pattern matching
โโโ safety/ # Memory safety checks
โโโ traits/ # Trait system
โโโ action/ # GitHub Actions integration
packages/
โโโ vscode-ion/ # VSCode extension with:
โโโ Language Server Protocol (LSP)
โโโ Debug Adapter Protocol (DAP)
โโโ Time-travel debugging
โโโ Memory profiling with leak detection
โโโ CPU profiling with flame graphs
โโโ Multi-threaded debugging (deadlock detection)
โโโ GC profiling with pressure analysis
โโโ Chrome DevTools format export
import http_router { Router }
let router = Router.init()
// Route parameters
router.get("/user/:id", handler)
// Middleware
router.use(logger_middleware)
router.use(auth_middleware)
// Route groups
let api = router.group("/api")
api.get("/users", get_users)
api.post("/users", create_user)
// JSON responses
fn handler(req: Request) Response {
return Response.json(.{ message = "Hello!" })
}
import database { Connection }
let conn = Connection.open(":memory:")
// Execute SQL
conn.exec("CREATE TABLE users (id INTEGER, name TEXT)")
// Prepared statements
let stmt = conn.prepare("INSERT INTO users VALUES (?, ?)")
stmt.bind_int(1, 42)
stmt.bind_text(2, "Alice")
stmt.step()
// Query with iteration
let result = conn.query("SELECT * FROM users")
while (result.next()) |row| {
print("User: {s}", row.get_text(1))
}
// Query builder
let builder = QueryBuilder.init()
.from("users")
.where("age > 18")
.order_by("name DESC")
.limit(10)
let sql = builder.build() // Generates SQL string
import queue { Queue, QueueConfig }
let config = QueueConfig.default()
let queue = Queue.init(config)
// Dispatch jobs
queue.dispatch("emails", "send_welcome_email")
queue.dispatch_sync("logs", "write_log") // Execute immediately
queue.dispatch_after(60, "cleanup", "purge_cache") // Delayed
// Process jobs
let worker = Worker.init(&queue)
worker.work(job_handler)
// Batch processing
let batch = Batch.init("batch_001")
batch.add(job1)
batch.add(job2)
batch.dispatch(&queue)
// Monitor queue
print("Pending: {}", queue.pending_count())
print("Failed: {}", queue.failed_count())
queue.retry_failed() // Retry all failed jobs
Ion uses a workspace-based monorepo structure:
ion.toml
)[package]
name = "ion-database"
version = "0.1.0"
authors = ["Ion Contributors"]
description = "SQL database access with SQLite driver"
license = "MIT"
[dependencies]
ion-diagnostics = { path = "../diagnostics" }
[scripts]
test = "zig test src/database.zig"
bench = "zig build bench"
ion.toml
)[package]
name = "ion"
version = "0.1.0"
[workspaces]
packages = ["packages/*"]
[scripts]
build = "zig build"
test = "zig build test"
format = "find src packages -name '*.zig' -exec zig fmt {} +"
# Install from registry (planned)
ion add http database queue
# Install from GitHub
ion add github:user/repo
# Install from Git URL
ion add https://github.com/user/repo.git
# Install specific version
ion add [email protected]
Ion has comprehensive test coverage across all packages:
# Run all tests (200+ tests)
zig build test
# Test specific package
zig test packages/database/tests/database_test.zig
# Run with verbose output
zig build test --summary all
# Run benchmarks
zig build bench
Ion features a modern testing framework inspired by Vitest and Jest:
import { test, expect, describe, mock, snapshot } from '@ion/testing'
describe('User API', () => {
test('creates user successfully', async () => {
const user = await createUser({ name: 'Alice' })
expect(user.name).toBe('Alice')
expect(user).toMatchSnapshot()
})
test('handles validation errors', () => {
const mockDb = mock(database)
mockDb.save.mockReject(new Error('Invalid email'))
expect(() => createUser({})).toThrow('Invalid email')
})
})
Features:
Test Statistics:
Ion includes a comprehensive VSCode extension with professional-grade debugging and profiling tools:
# From the Ion repository
cd packages/vscode-ion
npm install
npm run compile
# Install in VSCode
# Open Command Palette (Cmd+Shift+P)
# Run: Extensions: Install from VSIX
Step backward and forward through execution history:
// Automatically records snapshots during debugging
// Use debugger controls to step back/forward
// View variable changes between any two points
Track allocations and detect leaks:
Sample-based performance profiling:
Debug concurrent programs safely:
Analyze GC performance:
Available in VSCode Command Palette:
Ion: Start Debugging
Ion: Start CPU Profiler
Ion: Stop CPU Profiler
Ion: Generate Flame Graph
Ion: Export Chrome DevTools Profile
Ion: Start Memory Profiler
Ion: Stop Memory Profiler
Ion: Take Memory Snapshot
Ion: Generate Memory Report
Ion: Start GC Profiler
Ion: Stop GC Profiler
Ion: Analyze GC Pressure
Ion: Time-Travel: Step Back
Ion: Time-Travel: Step Forward
Ion: Multi-thread: Show Deadlocks
Ion: Multi-thread: Show Race Conditions
zig build example-router
Creates an HTTP server with:
/user/:id
)/api/v1/*
)zig build example-database
Demonstrates:
zig build example-queue
Shows:
zig build example-fullstack
Combines HTTP + Database + Queue for a complete application.
// Ownership (implicit, no ceremony)
let data = read_file("config.ion") // data owns the string
// Automatic borrowing
fn process(data: string) { // compiler infers &string
print(data.len())
}
process(data) // auto-borrow
print(data) // still valid!
// Explicit ownership transfer
fn consume(data: string) { // takes ownership
// data is moved here
}
consume(data)
// print(data) // Error: value moved
fn read_config() -> Result<Config> {
let file = fs.read_file("config.ion")? // ? propagates errors
let config = json.parse(file)?
return Ok(config)
}
match read_config() {
Ok(config) => app.start(config),
Err(e) => log.error("Failed: {e}")
}
// Or unwrap with default
let config = read_config().unwrap_or(Config.default())
fn fetch_users() -> async []User {
let tasks = [
http.get("/users/1"),
http.get("/users/2"),
http.get("/users/3"),
]
return await Promise.all(tasks)
}
// Concurrent database queries
fn get_dashboard_data() -> async Dashboard {
let [users, posts, stats] = await Promise.all([
db.query("SELECT * FROM users"),
db.query("SELECT * FROM posts"),
db.query("SELECT COUNT(*) FROM analytics"),
])
return Dashboard { users, posts, stats }
}
// Run at compile time
comptime fn generate_routes() -> []Route {
return fs.glob("routes/**/*.ion")
.map(|path| Route.from_path(path))
}
const ROUTES = generate_routes() // executed during compilation
// Compile-time SQL validation
comptime fn validate_query(sql: string) {
let parsed = sql_parser.parse(sql)
if (!parsed.is_valid()) {
@compile_error("Invalid SQL: " ++ sql)
}
}
// Use at compile time
comptime validate_query("SELECT * FROM users WHERE id = ?")
match value {
Ok(x) if x > 0 => print("Positive: {x}"),
Ok(0) => print("Zero"),
Ok(x) => print("Negative: {x}"),
Err(e) => print("Error: {e}")
}
// Destructuring
match point {
Point { x: 0, y: 0 } => print("Origin"),
Point { x, y: 0 } => print("On x-axis at {x}"),
Point { x: 0, y } => print("On y-axis at {y}"),
Point { x, y } => print("Point ({x}, {y})")
}
// Enum matching
match response {
HttpResponse.Ok(body) => send(body),
HttpResponse.NotFound => send_404(),
HttpResponse.Error(code, msg) => log_error(code, msg),
}
fn map<T, U>(items: []T, f: fn(T) -> U) -> []U {
let result = []U.init(items.len)
for (item, i in items) {
result[i] = f(item)
}
return result
}
struct Result<T, E> {
value: union {
Ok(T),
Err(E)
}
fn unwrap(self) -> T {
match self.value {
Ok(v) => return v,
Err(e) => panic("Called unwrap on Err: {e}")
}
}
fn unwrap_or(self, default: T) -> T {
match self.value {
Ok(v) => return v,
Err(_) => return default
}
}
}
Benchmark | Ion Target | Zig Baseline |
---|---|---|
Hello World | <50ms | ~70ms |
1000 LOC | <500ms | ~700ms |
10K LOC | <3s | ~5s |
Incremental (1 file) | <50ms | ~150ms |
Benchmark | Ion Target | Zig/C |
---|---|---|
Fibonacci | ยฑ5% | baseline |
HTTP throughput | ยฑ5% | baseline |
Memory ops | ยฑ5% | baseline |
Database queries | ยฑ5% | baseline |
Benchmarks will be validated continuously starting Month 4
CONTRIBUTING.md
- How to contributeWe're looking for:
Q: Is Ion production-ready? A: Not yet. Ion has a working compiler infrastructure and 200+ passing tests, but the full language specification is still being implemented. Expect alpha release by Month 6, 1.0 by Month 24.
Q: Can I use Ion now? A: Yes, for experimentation! You can build the compiler, run the examples, and explore the standard library. Not recommended for production use yet.
Q: How can Ion be faster than Zig? A: Aggressive IR caching at function level + parallel compilation + simpler type system. Will be validated via continuous benchmarking starting Month 4.
Q: Why another systems language? A: Because none of Zig, Rust, Go, or C give us all three: speed + safety + joy. Ion does.
Q: What about garbage collection? A: No GC. Manual memory management with ownership/borrowing for safety.
Q: What platforms are supported? A: Currently developing on macOS/Linux. Windows and WASM support planned for Phase 4-6.
Q: How is this funded? A: Open source, community-driven. Considering sponsorships/grants for sustainability.
Q: Why Zig for bootstrapping? A: To learn from Zig's strengths/weaknesses while building a fast foundation. Self-host in Ion at Phase 6.
Q: What about C interop? A: Full C interop planned. You can already see this in the database package (SQLite bindings).
Q: Does Ion have a package registry? A: Not yet. Packages currently installed from Git. Official registry planned for Phase 1.
Q: What makes Ion's debugging tools special? A: Ion includes time-travel debugging (step backward through execution), automatic deadlock detection for multi-threaded programs, memory leak detection, CPU flame graphs, and GC pressure analysis - all integrated into VSCode. Most languages don't have this level of tooling out of the box.
Q: Can I use Ion's testing framework now? A: Yes! The testing framework is fully functional with snapshot testing, mocks, async support, and benchmarking utilities. It's inspired by Vitest and Jest but designed for systems programming.
Ion | Zig | Rust | Go | C++ | |
---|---|---|---|---|---|
Compile speed | โกโกโก | โกโก | โก | โกโกโก | โก |
Memory safety | โ | โ ๏ธ | โ | โ GC | โ |
Learning curve | ๐ | ๐ค | ๐ฐ | ๐ | ๐ฑ |
Async/await | โ * | โ | โ ๏ธ | โ | โ ๏ธ |
Comptime | โ * | โ | โ ๏ธ | โ | โ ๏ธ |
Package manager | โ | โ ๏ธ | โ | โ | โ |
IDE support | โ | โก | โ | โ | โ |
Modern testing | โ | โ ๏ธ | โ | โ | โ ๏ธ |
Time-travel debug | โ | โ | โ | โ | โ |
Database access | โ | โ ๏ธ | โ | โ | โ ๏ธ |
HTTP server | โ | โ ๏ธ | โ | โ | โ ๏ธ |
*Planned, not yet implemented
ion/
โโโ src/
โ โโโ main.zig # CLI entry point
โ โโโ ion.zig # Compiler library
โโโ packages/ # Core packages (27 total)
โ โโโ lexer/ # Tokenization
โ โโโ parser/ # AST generation
โ โโโ ast/ # Syntax tree
โ โโโ types/ # Type system
โ โโโ interpreter/ # Code execution
โ โโโ codegen/ # x64 generation
โ โโโ diagnostics/ # Error reporting
โ โโโ formatter/ # Code formatting
โ โโโ testing/ # Modern test framework
โ โโโ stdlib/ # Standard library
โ โโโ database/ # SQLite access
โ โโโ queue/ # Job processing
โ โโโ vscode-ion/ # VSCode extension with advanced tooling
โโโ examples/ # Usage examples
โ โโโ http_router_example.zig
โ โโโ database_example.zig
โ โโโ queue_example.zig
โ โโโ full_stack_zyte.zig
โโโ bench/ # Benchmarks
โโโ docs/ # Documentation
โโโ build.zig # Build configuration
โโโ ion.toml # Workspace configuration
MIT License
Free for individuals, academia, and private enterprise.
Ion stands on the shoulders of giants:
Thank you to the language design community for paving the way.
If you reference Ion in academic work:
@software{ion2025,
title = {Ion: A Systems Language for Speed, Safety, and Joy},
author = {Stacks.js Team and Contributors},
year = {2025},
url = {https://github.com/stacksjs/ion},
}
Built with โค๏ธ by the Stacks.js team and contributors
GitHub โข Discussions โข Issues