Miri: GPU-first
programming language
Write GPU kernels in the same statically typed language as your CPU code. Mark a binding
gpu, launch it with forall, and the compiler infers every upload, launch and readback.
Host code compiles to native machine code. Kernels compile to WGSL for Metal, Vulkan, DX12 and WebGPU.
See Miri in action
Clean syntax, powerful features, zero boilerplate. Pick a topic — every sample is real, runnable Miri.
use system.io
// Hello, Miri!
let name = "Miri"
println(f"Hello, {name}!")
use system.gpu
// gpu = device-resident; upload is visible at the binding
gpu let a = [1.0, 2.0, 3.0, 4.0]
gpu let b = [5.0, 6.0, 7.0, 8.0]
gpu var dst = [0.0, 0.0, 0.0, 0.0]
// one GPU thread per index; runs on the GPU because it captures device data
forall i in 0..4
dst[i] = a[i] + b[i]
// readback: the only host↔device copy in the program
let host = dst
println(f"{host[0]} {host[1]} {host[2]} {host[3]}")
use system.io
struct Point
x int
y int
fn offset(p Point, dx int, dy int) Point
Point(x: p.x + dx, y: p.y + dy)
fn main()
let p = Point(x: 1, y: 2)
let q = offset(p, 10, 20)
println(f"{q.x}, {q.y}")
use system.io
enum Shape
Circle(float)
Rect(float, float)
fn area(s Shape) float
match s
Shape.Circle(r): 3.14 * r * r
Shape.Rect(w, h): w * h
fn main()
let s = Shape.Circle(5.0)
println(f"Area: {area(s)}")
use system.io
use system.collections.list
use system.collections.map
// Dynamic list
var items = List([1, 2, 3])
items.push(4)
println(f"Length: {items.length()}")
// Key-value map
let scores = {"Alice": 95, "Bob": 87}
println(f"Alice: {scores['Alice']}")
use system.io
fn find(name String?)
if let Some(s) = name
println(f"Found: {s}")
fn main()
let val int? = 10
match val
Some(n): println(f"got {n}")
None: println("nothing")
let fallback = val ?? 0
println(f"value: {fallback}")
use system.io
fn status_code(code int) String
match code
200 | 201 | 202: "OK"
404: "Not Found"
500 | 501 | 502: "Internal Server Error"
503: "Service Unavailable"
c if code >= 300 and code < 400: f"Redirect {c}"
_: "Unknown"
for code in 200..504
println(f"{code}: {status_code(code)}")
use system.io.{println}
fn add(a int, b int) int: a + b
fn factorial(n int) int
1 if n <= 1 else n * factorial(n - 1)
fn main()
let result = add(3, 4)
println(f"3 + 4 = {result}")
println(f"10! = {factorial(10)}")
use system.io
class Animal
protected name String
fn init(n String)
self.name = n
fn speak()
println(f"I am {self.name}")
class Dog extends Animal
fn speak()
super.speak()
println("Woof!")
fn main()
let d = Dog(n: "Rex")
d.speak()
use system.io
trait Speakable
fn speak()
trait Describable extends Speakable
fn describe()
println("I am an animal")
class Dog implements Describable
fn speak()
println("Woof!")
fn main()
let d = Dog()
d.speak()
d.describe()
use system.io
fn apply(f fn(int) int, x int) int
f(x)
fn main()
var base = 100
let add = fn(n int) int: base + n
println(f"{add(42)}")
let double = fn(x int) int: x * 2
println(f"{apply(double, 7)}")
use system.io
use system.collections.list
fn inc(n out int)
n = n + 1
fn main()
// Copy-on-Write — assignment shares, mutation forks.
let a = List([1, 2, 3])
var b = a
b.push(4)
println(f"{a.length()} {b.length()}")
// `out` — explicit, in-place mutation through a function.
var x = 41
inc(x)
println(f"{x}")
use system.io
fn identity<T>(x T) T
x
struct Wrapper<T>
value T
fn main()
println(f"{identity(42)}")
println(f"{identity("hello")}")
let w = Wrapper<int>(value: 99)
println(f"{w.value}")
use system.io
use system.collections.list as L
fn main()
var items = L.List([1, 2, 3])
items.push(4)
println(f"{items.length()}")
// models/user.mi
use system.io
class User
public name String
fn init(n String)
self.name = n
public fn greet()
println(f"Hello, {self.name}")
// main.mi
use local.models.user
fn main()
let u = User(n: "Alice")
u.greet()
Built for the future
A modern language designed from the ground up.
GPU-First Programming
GPU kernels live alongside CPU code in the same language — no shader files, no FFI. Mark a binding gpu, launch with forall, and every upload, launch, and readback is visible in the source. Runs natively and in the browser via WebGPU.
AI-Assisted Development
Diagnostics come as JSON with a stable code and a help line, and miri fix applies the recorded repairs for you. Your coding agent reads the error and knows exactly what to change.
Miri for agents →
Memory Safety
Invisible ownership with optimized reference counting. Copy-on-Write collections give value semantics with reference-pass speed. The only memory keyword you ever write is out.
Native Compilation
Compiles to native machine code via Cranelift. Fast compilation, fast execution, small binaries.
Static Typing & Type Inference
Catch errors at compile time with a powerful type system that stays out of your way. Types are inferred where possible.
Testing Built In
Mark a function @test and run miri test — each test runs in its own subprocess, so a crash is a failure rather than a lost run. Attributes are a closed set, so a typo is a compile error, never a test that silently never runs.
And everything else a modern language owes you
- Clean syntax — indentation-based blocks, no braces, no semicolons.
- Pattern matching — exhaustive, with destructuring and guard clauses.
- Null safety —
T?marks a value that may be absent, and the compiler makes you check it. - Traits & generics — default methods, monomorphized at compile time.
- Classes & inheritance — constructors, visibility, abstract classes, virtual dispatch.
- First-class closures — capture by value; pass, store and return them.
- Batteries-included standard library — files, time, regex and JSON. Disk access is a capability you pass in, and nothing panics.
- Async & parallelism coming soon — async/await and parallel primitives.
Let your agent write it
Claude Code, Cursor, Codex and friends can write Miri from day one. The compiler tells them exactly what went wrong and how to fix it, and skill packs teach them the language.
# once: build the compiler and put it on PATH git clone https://github.com/miri-lang/miri.git cd miri && make install # in your project: give your agent the skill packs miri skill install
- Errors an agent can act on.
miri check --format jsongives every problem a stable code, its exact place, a one-line fix hint and often the edit itself. - Fixes in one call.
miri fix --applywrites the edits the compiler is sure of. - No guessing names.
miri view --type Listlists what a type really offers. - Tests it can read.
miri test --format jsonreports expected and actual values for every failure.
Running on your GPU. Right now.
These aren't videos. Every tile below is computed live on your graphics card, and each one is a real, CI-tested Miri program that compiles to WebGPU. Click any demo to play with it and read its source.
What is Miri?
Miri is a statically typed, natively compiled programming language with first-class
GPU programming built into the language rather than bolted on through a library. You mark data gpu
to make it device-resident and launch a kernel with forall. The compiler infers every upload, launch
and readback. Kernels compile to WGSL and run on Metal, Vulkan, DX12 and WebGPU. Host code compiles to native
machine code through Cranelift. There are no shader files, no FFI layer and no CUDA toolchain.