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, Foundation (incl. UserDefaults/FileManager persistence), SwiftUI, and a SwiftData subset.

Read the full architecture →

Implementation status

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

168 implemented · 3 partial · 1 missing (172 total)

363 implemented · 1 partial · 147 missing (511 total)

Foundation54%–60%

335 implemented · 32 partial · 248 missing (615 total)

SwiftUI0%–16%

0 implemented · 112 partial · 590 missing (702 total)

SwiftData9%–11%

10 implemented · 2 partial · 102 missing (114 total)

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.