Build applications with Osprey
Build native apps for Mac, Windows, iPhone, Android and the web with Osprey Native: one Osprey app, drawn by each platform's own widgets. Every app below is written in Osprey and runs today. The film shows Talon Bank on web, Android and iPhone, Issue Inbox, Storage, Vigil, Metal scenes, Prism and the Proof Workbench, with Windows shots from the WinUI host.
Desktop and mobile apps: Osprey Native
Osprey Native (@osprey/native) compiles one Osprey app (state, logic and UI) ahead of time to native code. Each host draws it with the platform's own widgets: SwiftUI on Mac and iPhone, WinUI on Windows, Android views on Android. FerroUI draws it on a GPU canvas, and the web host runs it through WebAssembly. Flutter and Compose Multiplatform draw their own copies of the widgets; React Native runs JavaScript in an engine. Osprey Native does neither.
Apps: Issue Inbox (iPhone and Android), Talon Bank (web, iPhone and Android), Storage (Mac, iPhone and Windows) and Osprey Agent, a native coding agent (Mac).
Start: Osprey Native guides · source
Vigil: security investigation for Mac and iPhone
Vigil reviews a Mac for signs of spyware: hidden startup paths in launch definitions, disabled macOS protections, and files that no longer match their recorded hashes. Every warning shows its evidence. The iPhone edition reviews reports imported from a Mac. The app's core, screens, rules and storage are Osprey on Osprey Native; Swift only draws the SwiftUI views. Vigil goes public soon.
Music: Perception
Perception is a music studio you can see all the way through. Every sound is a patch you can open, down to the Osprey source behind each module, and its DSP comes with formal proofs. Anything that reads untrusted input (project files, OSC packets, WAV files) is hunted with KLEE in CI. The full studio runs on macOS; Windows runs the patch editor. Songs render offline, then play.
Start: download Perception · source
Web servers
Osprey's HTTP and WebSocket servers run on fibers. Storage and the network sit behind effects, so a test swaps the real database for a fake one.
- Express on Osprey: Express applications in TypeScript flavor, compiled to a native binary.
- Examples: stateful HTTP, WebSocket server, PostgreSQL and Talon Bank's server.
AI and machine learning
GPT-2 runs from its published Hugging Face weights, generating text and taking training steps. It is written in Python flavor on Osprey's ports of numpy, torch and transformers.
The model's maths is written once; a handler decides whether it runs on the CPU or the GPU. The model asks for operations such as "multiply these matrices" through an algebraic effect called Tensor. One handler answers with lists on the CPU; another answers with GPU buffers on Metal or OpenCL. Tensor is a static effect, so the compiler builds a separate copy of the model for each handler and nothing is looked up at run time.
@static_effect
class Tensor[B]:
def build(size: int, kernel: Kernel) -> Result[B, str]:
def get(buffer: B, index: int) -> float32:
def mat_mul(a: B, b: B, rows: int, inner: int, cols: int) -> Result[B, str]:
def load(path: str, name: str) -> Result[B, str]:
def device() -> str:
The GPU handler passes the GPU's Result straight back, so a failed product or load stops the model with an Error instead of a made-up tensor:
def mat_mul(a, b, rows, inner, cols):
return answered(gpuMatMul(a, b, rows, inner, cols))
Run it from a built checkout. The first output line names the backend:
make -C src/toolchain/targets/llms gpt2 FLAVOR=python GPU=metal PROMPT="The capital of France is" TOKENS=20
The compiler checks that both handlers answer every operation with matching types and that GPU kernels perform no effects. A regression test runs a small transformer under both handlers. Limits: device-kernel faults currently abort instead of reaching an arithmetic handler, kernels are not fused, and GPU maths can differ from the CPU's in the last digit (GPU specification). GPT-2's README has timings.
A Qwen model and an Ollama-compatible server are in progress. See also Python packages.
WebAssembly
--target=wasm32 builds a WebAssembly module that runs under WASI in the browser or a server runtime.
osprey hello.osp --target=wasm32 --compile -o hello.wasm
- Playground: write and run Osprey in the browser.
- WebAssembly demo: an Osprey module computes a sales ledger with effects and union types, and a browser SQLite database loads its output for you to query.
WebAssembly rejects single-shot resumable (once) control effects at compile time; value effects and multi-shot (many) regions work.
Packages
Osprey Packages adds a dependency, records its exact source in osprey.lock, and builds offline. Browse the catalog at packages.ospreylang.dev.
Ship it
- Document your modules: HTML API references and tested examples from doc comments.
- Hunt for bugs: find inputs that crash your program with symbolic execution.
- Profiling: find hot functions and leaks.