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.
Clean Syntax
Indentation-based blocks, no braces or semicolons. Balanced readability, expressiveness, and safety.
AI-Assisted Development
Designed with clear, consistent semantics that make AI code generation and assistance highly effective.
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.
Native Compilation
Compiles to native machine code via Cranelift. Fast compilation, fast execution, small binaries.
Pattern Matching
Exhaustive pattern matching with destructuring across enums, structs, tuples, and literals. Guard clauses included.
Option Types & Null Safety
The ? type suffix marks values that may be absent. The compiler prevents use without checking — no null pointer errors.
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.
Classes & Inheritance
Full OOP with constructors, visibility modifiers, single inheritance, abstract classes, super calls, and runtime virtual dispatch via vtables.
Traits & Generics
Trait interfaces with default methods and inheritance chains. Generic functions, structs, and classes monomorphized at compile time.
First-Class Closures
Lambdas that capture variables by value. Pass them as arguments, store in variables, return from functions. Compiled to native fat pointers.
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.
Batteries-Included Standard Library
Files, the environment, time, regular expressions and JSON, alongside the collection types. Access to the outside world is a capability you pass in, so a function that cannot touch the disk says so in its signature. Nothing panics, and nothing hands back a sentinel.
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.
Async & Parallelism
First-class async/await and parallel primitives make concurrent programming intuitive and safe.
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.