Overview
UnifiedMozaic is a small, statically typed language with TypeScript-like syntax. It compiles through LLVM to native executables and WebAssembly, with no garbage collector, and lets you write CPU and GPU code in the same .um source.
Features
Section titled “Features”- TypeScript-like syntax, explicit types. Sized numeric types (
i8–i64,u8–u64,f16/f32/f64, and small floatsf4/f8),struct,class(no inheritance),enumwithmatch, interfaces, generics, strings, nullable types. No implicit conversions. - Ownership instead of GC. Arrays and other heap values have a single owner. Arguments are borrowed (default), mutably borrowed (
mut) or moved (own), checked at compile time. - Safe by default. Out-of-bounds access, integer division by zero and oversized shifts stop the program with a clear message; integer overflow wraps; there is no undefined behaviour and no
unsafe. - One source for CPU and GPU.
kernelfunctions have the same meaning on every backend. They run on a CPU thread pool, on Apple GPUs through Metal (MSL), and, experimentally, on WebGPU (WGSL).dispatchchooses CPU or GPU by measurement;gpu.submit/gpu.ready/gpu.waitrun GPU work asynchronously. - Threads.
thread.spawn/thread.join, withRacyBufferas the only shared mutable data (atomic element access, so no data races). - Low-level speed when you need it. 128-bit SIMD types (
i8x16,i16x8,f32x4, …),Math.prefetch, masked shifts, bounds-check elimination, bulkfill. - Diagnostics for humans and AI. Errors carry a code, a location and a hint, and
check --jsongives machine-readable diagnostics. - No npm dependencies. The compiler is plain TypeScript run directly by Node.js; the only external tool is
clang.
Example
Section titled “Example”struct Particle { pos: f32; vel: f32;}
// A kernel runs once per index, on the CPU (all cores) or on the GPU.kernel function integrate(i: u32, ps: mut Buffer<Particle>, dt: f32): void { ps[i].pos = ps[i].pos + ps[i].vel * dt;}
export function main(): i32 { let ps = new Buffer<Particle>(1000); // fixed length, zero-filled ps[0].vel = 2; dispatch(integrate, ps.length, mut ps, 0.5); print(ps[0].pos); // 1 return 0;}Project layout
Section titled “Project layout”src/ compiler: lexer → parser → checker → codegen (LLVM IR) → driver (clang) plus msl.ts (Metal) and wgsl.ts (WebGPU) kernel translatorsruntime/ native runtime (C), Metal runtime (Objective-C), wasm runtime and JS hostexamples/ sample programs (also tests)tests/ test runner and test casesassets/ logodocs/ documentationLicense
Section titled “License”UnifiedMozaic is licensed under either of the Apache License, Version 2.0 or the MIT license, at your option.
For the security policy and how to report a vulnerability, see SECURITY.md.