swift → rust → wasm

A toy Swift for the browser,
in Rust.

tswift parses, type-checks, and runs Swift entirely in Rust — no LLVM, no Clang, no Swift toolchain. The same Rust binary compiles to WebAssembly so you can run Swift code right here in the browser, at fraction of the size for full Swift.

main.swift0 lines
loading…
Output
Ready.

How it works

A pure-Rust pipeline from Swift source to output, with no C dependencies.

Swift source
tswift-lexer
tswift-parser
tswift-sema
tswift-frontend
Typed AST
Runtime evaluator
Output
🔍

Frontend Pipeline

Pure-Rust lexer → AST → parser → semantic analysis. No C, no LLVM, no unsafe code.

⚙️

Runtime Evaluator

Tree-walking interpreter with ARC via Rc, copy-on-write value semantics, and native closures.

📦

Libraries

Native Rust implementations of Swift's stdlib, with Foundation and SwiftUI on the roadmap.

Read the full architecture →

Implementation status

tswift covers 8 tiers of the Swift 6.3 language surface, plus stdlib and Foundation.

Standard Library73% (19/26)
Foundation17% (2/12)
SwiftUI4% (29/658)
Full status dashboard →

Why Rust?

Rust's ownership model maps onto Swift's memory semantics surprisingly well.

Memory safety, for free

Swift's ARC becomes Rc<RefCell<T>> in Rust. Value-type copy-on-write becomes Rc::make_mut. Deterministic deinit maps to Drop. No unsafe anywhere in the stack.

One binary → WebAssembly

The same Rust crate compiles to native (fast CLI) and towasm32-unknown-unknown (browser). No platform-specific shims — the interpreter just runs.

Semantic alignment

SwiftRust
Value-type CoWRc::clone + Rc::make_mut
class ARCRc<RefCell<Object>>
deinitDrop at strong-count 0
weak (zeroing)rc::Weak + .upgrade()
overflow trapchecked_add / wrapping_add
UTF-8 StringRust String

Golden fixture testing

Every feature has a .swift + .expected golden fixture. The harness runs each through the CLI and diffs stdout. 53+ fixtures pass end-to-end today.