RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Raya

One language, from the GPU kernel to the app.

Raya is Riptide's programming language: its compiler, runtime and SDK. It's open source, with sound null safety, a fast VM with hot reload for development and ahead-of-time native code, and it adds what engines, operating systems and machine learning need: exact maths, values that live in registers, native SIMD and the CPU's matrix unit.

And it comes with a whole maths stack: Riptide's own NumPy- and SciPy-style libraries, arbitrary precision and computer algebra, more than 85,000 lines written in Raya.

import 'raya:convert';

enum Size { small, large }

data class Item(final String name, final double price, final Size size, final List<int> tags);

data class Order(final String id, final List<Item> items);

void main() {
  final tea = Item('tea', 2.5, Size.large, [1, 2]);
  print(tea);
  print(tea.copyWith(price: 3.0));

  // Collections compare by content, so these are equal.
  print(tea == Item('tea', 2.5, Size.large, [1, 2]));

  final order = Order('A-17', [tea, Item('cake', 4.0, Size.small, [])]);
  final json = jsonEncode(order.toJson());
  print(json);
  final back = Order.fromJson(jsonDecode(json) as Map<String, Object?>);
  print(back == order);
}
Output · Runs in your browser
Item(name: tea, price: 2.5, size: Size.large, tags: [1, 2])
Item(name: tea, price: 3.0, size: Size.large, tags: [1, 2])
true
{"id":"A-17","items":[{"name":"tea","price":2.5,"size":"large","tags":[1,2]},{"name":"cake","price":4.0,"size":"small","tags":[]}]}
true
// Quadrance: the squared distance. For whole-number points it is a whole number.
int quadrance((int, int) a, (int, int) b) {
  final dx = b.$1 - a.$1, dy = b.$2 - a.$2;
  return dx * dx + dy * dy;
}

// Spread between directions u and v: (u × v)² / (Q(u) Q(v)), as a fraction: 0 for parallel, 1 for perpendicular.
(int, int) spread((int, int) u, (int, int) v) {
  final cross = u.$1 * v.$2 - u.$2 * v.$1;
  final num = cross * cross;
  final den = (u.$1 * u.$1 + u.$2 * u.$2) * (v.$1 * v.$1 + v.$2 * v.$2);
  final g = num.gcd(den);
  return (num ~/ g, den ~/ g);
}

String frac((int, int) f) => f.$2 == 1 ? '${f.$1}' : '${f.$1}/${f.$2}';

void main() {
  const a = (0, 0), b = (4, 0), c = (1, 3);
  final q1 = quadrance(b, c), q2 = quadrance(a, c), q3 = quadrance(a, b);
  print('quadrances: Q1 = $q1, Q2 = $q2, Q3 = $q3');

  final sA = spread((b.$1 - a.$1, b.$2 - a.$2), (c.$1 - a.$1, c.$2 - a.$2));
  final sB = spread((a.$1 - b.$1, a.$2 - b.$2), (c.$1 - b.$1, c.$2 - b.$2));
  final sC = spread((a.$1 - c.$1, a.$2 - c.$2), (b.$1 - c.$1, b.$2 - c.$2));
  print('spreads:    s_A = ${frac(sA)}, s_B = ${frac(sB)}, s_C = ${frac(sC)}');

  // Spread law: s_A / Q1 = s_B / Q2 = s_C / Q3, checked by cross-multiplying integers.
  print('spread law holds exactly: '
      '${sA.$1 * sB.$2 * q2 == sB.$1 * sA.$2 * q1 && sB.$1 * sC.$2 * q3 == sC.$1 * sB.$2 * q2}');

  // A right angle has spread exactly 1. Perpendicular directions:
  print('spread of (3, 4) and (-4, 3): ${frac(spread((3, 4), (-4, 3)))}');
  // Parallel directions have spread exactly 0:
  print('spread of (2, 6) and (1, 3):  ${frac(spread((2, 6), (1, 3)))}');
}
Output · Runs in your browser
quadrances: Q1 = 18, Q2 = 10, Q3 = 16
spreads:    s_A = 9/10, s_B = 1/2, s_C = 4/5
spread law holds exactly: true
spread of (3, 4) and (-4, 3): 1
spread of (2, 6) and (1, 3):  0
import 'package:riptide_numerics_cpu/riptide_numerics_cpu.ray' as np;
import 'package:riptide_numerics_cpu/linalg.ray' as la;

void main() {
  final a = np.NDArray.fromList([
    [4.0, -2.0, 1.0],
    [-2.0, 4.0, -2.0],
    [1.0, -2.0, 4.0],
  ]);
  final b = np.NDArray.fromList([11.0, -16.0, 17.0]);

  final x = la.solve(a, b);              // solve a·x = b
  print('x = $x');
  print('det = ${la.det(a)}');

  final r = la.svd(a);                   // singular values
  print('singular values = ${r.s}');

  final e = la.eigh(a);                  // symmetric eigenvalues
  print('eigenvalues = ${e.values}');
}
Output · Runs in your browser
x = array([1., -2., 3.])
det = array(36.)
singular values = array([7.3722813, 3., 1.6277187])
eigenvalues = array([1.6277187, 3., 7.3722813])
import 'package:riptide_cas/riptide_cas.ray';

void main() {
  final x = Sym('x');
  final f = Expr.parse('x^3 * sin(x)');

  print('f        = $f');
  print("f'       = ${f.diff(x)}");
  print('∫ x² dx  = ${integrate(Expr.parse('x^2'), x)}');
  print('expand   = ${Expr.parse('(x + 1)^4').expand()}');
  print('factor   = ${factor(Expr.parse('x^4 - 1'))}');
  print('solve    = ${solve(Expr.parse('x^2 - 5*x + 6'), x)}');
  print('series   = ${series(Expr.parse('exp(x)'), x, n: 5)}');
  print('LaTeX    = ${f.diff(x).toLatex()}');
}
Output · Recorded on the Raya VM, an M1 Pro MacBook Pro
f        = x**3*sin(x)
f'       = x**3*cos(x) + 3*x**2*sin(x)
∫ x² dx  = x**3/3
expand   = x**4 + 4*x**3 + 6*x**2 + 4*x + 1
factor   = (x - 1)*(x + 1)*(x**2 + 1)
solve    = [2, 3]
series   = 1 + x + x**2/2 + x**3/6 + x**4/24 + O(x**5)
LaTeX    = x^{3} \cos{\left(x \right)} + 3 x^{2} \sin{\left(x \right)}
import 'raya:ffi';
import 'raya:typed_data';

@Native<Int32 Function()>(symbol: 'raya_matrix_features', isLeaf: true)
external int matrixFeatures();

@Native<Void Function(Pointer<Int8>, Pointer<Int8>, Pointer<Int32>, Int64, Int64, Int64, Int64)>(
    symbol: 'raya_matmul_i8', isLeaf: true)
external void matmulI8(Pointer<Int8> a, Pointer<Int8> b, Pointer<Int32> c, int m, int n, int k, int bRows);

@Native<Void Function(Pointer<Int16>, Pointer<Int16>, Pointer<Int64>, Int64, Int64, Int64, Int64)>(
    symbol: 'raya_matmul_i16', isLeaf: true)
external void matmulI16(Pointer<Int16> a, Pointer<Int16> b, Pointer<Int64> c, int m, int n, int k, int bRows);

void main() {
  final f = matrixFeatures();
  print('matrix unit: f32 ${f & 1 != 0}, int8 ${f & 2 != 0}, int16 ${f & 4 != 0}');

  // A is 2 x 3, B is 3 x 2.
  final a = Int8List.fromList([1, 2, 3, 4, 5, 6]);
  final b = Int8List.fromList([7, 8, 9, 10, 11, 12]);
  final c = Int32List(4);
  matmulI8(a.address, b.address, c.address, 2, 2, 3, 0);
  print('int8 A·B   = $c');

  // int16 in, int64 out: the extreme value squared three times, exact.
  final w = Int16List.fromList([-32768, -32768, -32768]);
  final big = Int64List(1);
  matmulI16(w.address, w.address, big.address, 1, 1, 3, 1);
  print('int16 dot  = ${big[0]} (expected ${3 * 32768 * 32768})');
}
Output · Recorded on the Raya VM, an M1 Pro MacBook Pro
matrix unit: f32 false, int8 false, int16 false
int8 A·B   = [58, 64, 139, 154]
int16 dot  = 3221225472 (expected 3221225472)
import 'raya:concurrent';
import 'raya:isolate';
import 'raya:typed_data';

@pragma('vm:shared')
final Int64List hits = Int64List(1);

@pragma('vm:shared')
final Mutex lock = Mutex();

void work(int n) {
  for (var i = 0; i < n; i++) {
    lock.runLocked(() => hits[0]++);
  }
}

Future<void> main() async {
  await Future.wait([
    for (var i = 0; i < 4; i++) Isolate.run(() => work(1000)),
  ]);
  print('hits: ${hits[0]}');   // one counter, four workers
}
Output · Recorded on the Raya VM, an M1 Pro MacBook Pro
hits: 4000

Real programs from the playground, with the output they printed.

Raya vs C, measured

The code, and the numbers.

Two of the benchmarks, trimmed to their core. Each is built with raya compile exe and checked against C and C++ for the same answer.

// matmul.ray: exact int8 × int8 → int32 matrix multiply, n×n
import 'raya:ffi';
import 'raya:typed_data';

// The Raya runtime's exact int8 matrix multiply
@Native<Void Function(Pointer<Int8>, Pointer<Int8>, Pointer<Int32>,
    Int64, Int64, Int64, Int64)>(symbol: 'raya_matmul_s8s8_i32', isLeaf: true)
external void matmulI8(Pointer<Int8> a, Pointer<Int8> b, Pointer<Int32> c,
    int m, int n, int k, int bRows);

void main() {
  const n = 2048;
  final a = Int8List(n * n), b = Int8List(n * n), c = Int32List(n * n);
  for (var i = 0; i < n * n; i++) {
    a[i] = (i * 7919) % 255 - 127;
    b[i] = (i * 104729 + 13) % 255 - 127;
  }
  final t = Stopwatch()..start();
  matmulI8(a.address, b.address, c.address, n, n, n, 0);
  print('${t.elapsedMicroseconds / 1000} ms');  // every result exact
}
$ raya compile exe matmul.ray && ./matmul
int8 → int32, 2048³: 3.99 ms · C 337 ms · 84× faster
$ raya compile exe binary_trees.ray && ./binary_trees
binary-trees, depth 18: 403 ms · C 620 ms · C++ 794 ms

Exact int8 matrix multiply, 2048³84×on the CPU's matrix unit, every result matches C

Raya
3.99 ms
C
337 ms

binary-trees, depth 181.97×vs C++ with std::unique_ptr

Raya
403 ms
C
620 ms
C++
794 ms

Exact geometry, 8M vector pairs1.66×Raya gets every pair right; C and C++ miss 160

Raya
36.0 ms
C
59.9 ms
C++
60.4 ms

Apple M5 Pro, clang 21 -O3, 15 shuffled runs, medians. Where C still wins is listed too, in docs/benchmarks.md. More M5 matrix results.

Raya's maths libraries

Not just a language. A whole maths stack.

Riptide wrote its own versions of the libraries scientists and engineers use every day: arrays and linear algebra, SciPy's calculus, signal, sparse, spatial, special and statistics modules, arbitrary precision, computer algebra, and much more. More than 85,000 lines, all written in Raya, many with exact versions that floating point can't give you. Tap any library to open it here, with every class and method.

Browse every method in the docs → Or open them in the playground

40libraries, core included
13,359classes and methods, all documented on the site
85,000+lines of maths written in Raya

Numerical computing

Arrays and linear algebra

n-dimensional arrays with NumPy semantics: float16, bfloat16 and complex dtypes, views, slicing, broadcasting, ufuncs, reductions, matmul and einsum. BLAS levels 1–3, LU, Cholesky, LDLᵀ, QR, SVD, eigenvalues, Schur, least squares and matrix functions.

What NumPy and LAPACK do
297 functions · 29 typesRun a lesson →

Calculus and solvers

Automatic differentiation, ODE solvers (explicit, stiff, symplectic, batched), B-spline, NURBS and RBF interpolation, quadrature, root finding and optimisation.

What scipy.integrate, interpolate and optimize do
326 functions · 52 typesRun a lesson →

FFT and signal processing

Mixed-radix and Bluestein FFT, real and n-D FFT, DCT, convolution, FIR and IIR filter design, windows, resampling and spectral analysis.

What numpy.fft and scipy.signal do
105 functions · 18 typesRun a lesson →

Sparse linear algebra

COO, CSR, CSC and BSR matrices, SIMD sparse products, Krylov solvers (CG, PCG, GMRES, BiCGSTAB, MINRES) with Jacobi, ILU(0) and IC(0) preconditioners, reorderings and sparse Cholesky.

What scipy.sparse does
81 functions · 21 typesRun a lesson →

Spatial structures

KD-trees, ball trees and BVHs, 2-D and 3-D convex hulls, Delaunay and Voronoi, k-nearest neighbours, point clouds and Morton codes.

What scipy.spatial does
82 functions · 13 typesRun a lesson →

Special functions

Gamma and beta (complete and incomplete), the erf family, Bessel J, Y, I and K, Airy, elliptic integrals, Legendre and spherical harmonics, zeta and hypergeometric functions, tested against SciPy and mpmath.

What scipy.special does
63 functions · 1 typesRun a lesson →

Statistics and random numbers

Counter-based Philox and Threefry generators that give the same bits on the CPU and the GPU, distributions with pdf, cdf and ppf, descriptive statistics, regression, PCA and k-means.

What scipy.stats does
142 functions · 22 typesRun a lesson →

GPU numerics

Dense and batched GEMM, Cholesky and LU, sparse products, random numbers and BVH queries as GPU compute kernels on Metal and Vulkan.

64 functions · 16 types

Tensors

A tensor API that records a graph, runs it on the CPU while you develop, and compiles it to GPU kernels. Riptorch’s engine grew from here.

130 functions · 23 typesRun a lesson →

Exact and higher mathematics

Arbitrary precision

Exact rationals, binary floating point of any precision with correctly rounded operations, interval and ball arithmetic, and elementary and special functions to any precision.

What MPFR and mpmath do
387 functions · 15 typesRun a lesson →

Computer algebra

Symbolic expressions, simplification, expansion and factorisation, differentiation, integration, series, multivariate polynomials, Gröbner bases, solving and LaTeX output.

What SymPy does
374 functions · 26 typesRun a lesson →

Algebra and number theory

Permutation groups and character tables, Lie groups and algebras, Clifford algebras and spinors, quaternions and octonions, exact real algebraic numbers, primes, elliptic curves and modular forms.

845 functions · 49 typesRun a lesson →

Rational trigonometry

Quadrance and spread instead of distance and angle, over the rationals and finite fields: the five main laws, conics, exact rotations, projective and universal hyperbolic geometry, chromogeometry and exact geometric predicates.

468 functions · 53 typesRun a lesson →

Algebraic calculus

Calculus done exactly over the rationals and prime fields, with polynumbers and subderivatives, tangents with no limits, signed areas and quadratic curvature.

212 functions · 16 typesRun a lesson →

Exact special functions

Special functions for rational trigonometry: spread polynomials, spread periods, the Cayley circle and spread series, next to their classic counterparts.

93 functions · 9 typesRun a lesson →

Differential geometry

Index-notation tensors, metrics and curvature by exact second-order differentiation, differential forms with wedge, d and Hodge star, discrete exterior calculus on meshes, and Lorentz and spinor transformations.

174 functions · 13 typesRun a lesson →

Topology

Homology and cohomology over the integers and Z/p, persistent homology (Vietoris–Rips, alpha, cubical), mapper, discrete Morse theory and 3-manifolds.

What GUDHI and Ripser do
179 functions · 28 typesRun a lesson →

Knot theory

Link diagrams and Reidemeister moves, exact Jones, Alexander, Conway and HOMFLY-PT polynomials, and a table of small knots and links.

124 functions · 12 typesRun a lesson →

Gauge fields

Superconductivity as a lattice Higgs model stepped by exact rational updates: U(1) links as rational unit complex numbers turned by Cayley maps, next to the classic angle form.

150 functions · 16 typesRun a lesson →

Lattice gauge theory

U(1) gauge symmetry as code, and lattice gauge theory for U(1), SU(2) and SU(3) with the Wilson action.

48 functions · 3 types

Geometry, physics and speed

The CPU matrix unit

Matrix multiply on the matrix unit (SME on M4, M5 and A18; a portable path elsewhere) for float32, exact int8 → int32 and int16 → int64.

5 functions · 1 typesRun a lesson →

SIMD helpers

SIMD helpers over Float32x4, Int32x4 and Float64x2 that compile to single NEON instructions on arm64.

105 functions · 6 typesRun a lesson →

Arrays of value-class structs

StructList: a fixed-length list of value-class instances stored contiguously, with no per-element objects.

7 functions · 1 types

Physics

Rigid bodies with contacts and joints, cloth and soft bodies, SPH and stable fluids, finite elements and heat, orbital mechanics and typed units.

355 functions · 66 typesRun a lesson →

Quantum mechanics

The Schrödinger equation stepped exactly over the Gaussian rationals, so probability is conserved exactly, rational SU(2) spin rotors and entanglement.

248 functions · 32 typesRun a lesson →

Relativity

Special relativity as red geometry with exact velocity composition, and light and orbits around a black hole traced with only + − × ÷.

114 functions · 17 typesRun a lesson →

Kepler orbits

Kepler orbits turned into a harmonic oscillator and stepped exactly, next to the classic leapfrog and Kepler-equation methods.

81 functions · 11 typesRun a lesson →

Core libraries

Core types

Strings, numbers, BigInt, booleans, lists, maps, sets, iterables, dates and durations, URIs, regular expressions, errors and exceptions. Imported automatically.

622 functions · 60 types

JSON, UTF-8 and encodings

Codecs and converters: JSON, UTF-8, Latin-1, ASCII, Base64, HTML escaping and line splitting.

123 functions · 28 types

More collections

Hash, linked and splay-tree maps and sets, queues, linked lists, and list and map helpers.

338 functions · 23 types

Futures, streams and timers

Future, Stream, stream controllers and transformers, Completer, Timer, zones and microtasks.

193 functions · 33 types

Files, processes, sockets and HTTP

Files and directories, processes, standard input and output, sockets, an HTTP client and server, and WebSockets.

598 functions · 106 types

Calling C (FFI)

Pointers, native types, structs and unions, dynamic libraries, callbacks and native memory.

262 functions · 102 types
Measured against C

Faster than C, and exact.

Same algorithms, every result checked, on an Apple M5 Pro against Apple clang -O3.

84×
exact int8 matrix multiply, 2048 × 2048
3.99 ms vs 337 ms for C · 68× at 1024 · every result matches
2.5×
float64 matrix multiply on one core
5.4 ms vs 13.6 ms for C with Apple's Accelerate · bit for bit
1.66×
exact geometry, 8 million 3D vector pairs
36.0 ms vs 59.9 ms · C with sqrt and acos missed 160 pairs; Raya got every one
1.97×
binary-trees
vs C++ · 1.54× vs C
1.25×
spectral-norm
vs C and C++
7.6×
less code: an ACPI interpreter
4,629 lines of Raya vs 35,413 lines of C (uACPI)
How many times faster Raya is than C and C++: 84× and 68× on exact int8 matrix multiply, 2.5× on float64 vs Apple Accelerate, 1.54× vs C and 1.97× vs C++ on binary-trees, 1.66× on exact geometry, 1.38× on float32, 1.25× on spectral-norm, 1.32× on a hash map vs C++ Matrix multiply in milliseconds: Raya 0.63 vs C 42.9 (int8 1024³), 3.99 vs 337 (int8 2048³), 5.42 vs 13.6 (float64), 1.18 vs 1.62 (float32) binary-trees: Raya 403 ms, C 620, C++ 794; spectral-norm: Raya 221, C and C++ 276; exact geometry: Raya 36.0, C 59.9, C++ 60.4 Exact geometry: Raya 0 wrong answers; C and C++ 160 wrong each

Apple M5 Pro, macOS 27.2.1, Raya vs Apple clang 21.0.0 -O3, 15 rounds in shuffled order, November 24, 2026. Every benchmark, including where C is still ahead. All our Apple M5 matrix results, Raya and Riptorch. Accelerate: Apple's BLAS. Exact geometry: one thread each.

In the language today

Built for speed you can trust.

Value classes

No identity, so vectors, rotors and fractions live in registers instead of on the heap. @pragma('raya:value')

Allocation-free hot loops

Escape analysis turns records and value classes into registers: the inner loop allocates nothing.

Native SIMD

Float32x4, Int32x4 and Float64x2 become single NEON instructions on Apple silicon, with int8 dot products.

The CPU's matrix unit

Matrix maths in the runtime: exact int8 → int32 and int16 → int64, and float32, on the matrix hardware (SME).

Data classes

==, hashCode, toString and copyWith from the primary constructor. No build_runner.

Every core

Parallel ahead-of-time compilation, and shared data between parallel workers.

Landing next

  • Value-class fields stored inline, one unboxed slot per field
  • Bounds checks hoisted out of loops: one proven guard per loop nest
  • JSON for data classes, with no code generator
  • Compile-time functions: const functions that run while you build

Every change to the language ships with the test that guards it, and the main branch only moves when every test passes.

Built in Raya

We write everything we can in Raya.

Riptorch

A machine-learning framework that runs PyTorch code: its engine (tensors, autograd) is written in Raya. import riptorch as torch

An operating system's ACPI interpreter

Written from the public ACPI 6.5 specification in about 4,600 lines, where the C library it replaces is about 35,000. No dependencies beyond raya:.

A real-time 3D renderer

Physically based materials, image-based lighting, soft shadows, glTF 2.0, character animation with IK, automatic levels of detail and digital humans, on Metal and Vulkan.

Physics

Rigid bodies, cloth and soft bodies, fluids, finite elements and heat, orbital mechanics, and typed SI units.

Compiler

Plain Raya loops, faster than C.

Write an ordinary integer loop. The Raya compiler recognises dot products, polynomial products, matrix products, filters and 2-D convolutions, runs them on the CPU's vector and matrix units, and keeps every answer exact. Faster than the better of gcc and clang at -O3 -march=native on every benchmark, on Graviton3, Graviton4, Sapphire Rapids, Ice Lake and Zen 4. On Raya main now, coming in the next release (not in 0.4.0).

See what the compiler does →

Every benchmark against gcc 13 and clang 18 on five CPUs, the exactness guarantees, and how to reproduce.

On GitHub

The same page in the Raya repository's docs.

Research

Exact number types built from msets.

Multiply polynomials exactly as counts, compose matrices exactly, and keep small rationals in two registers. Msets, polynumbers, maxels and nested boxes as Raya types, with their definitions and laws, measured against C, GMP and BigInt on Arm and x86, with every loss stated.

Read the research note →

Exact polynomial products faster than C’s loop and GMP from degree 256 to 1,024 on Graviton3; maxels and bipolynumbers 760 to 2,300 times faster than object versions; tallies and vexels lose to int and BigInt. Definitions, laws, worked examples, tests, 23 figures.

On GitHub

The same note in the Raya repository’s docs, under docs/raya/research/number-types.

Sponsor wall

Put your company on Raya.

Every developer who reads about Raya sees this wall. These spots are open: claim one, and your logo goes here and at the top of the Raya README.

Founding Partners

Your logo here: Founding Partner spot availableYour logo here: Founding Partner spot availableYour logo here: Founding Partner spot available

Gold sponsors

Your logo here: Gold sponsor spot availableYour logo here: Gold sponsor spot availableYour logo here: Gold sponsor spot availableYour logo here: Gold sponsor spot available

Silver sponsors

Your logo here: Silver sponsor spot availableYour logo here: Silver sponsor spot availableYour logo here: Silver sponsor spot availableYour logo here: Silver sponsor spot availableYour logo here: Silver sponsor spot available

Bronze sponsors

Your logo here: Bronze sponsor spot availableYour logo here: Bronze sponsor spot availableYour logo here: Bronze sponsor spot availableYour logo here: Bronze sponsor spot availableYour logo here: Bronze sponsor spot availableYour logo here: Bronze sponsor spot available
Get Raya

Raya 0.4.0 is out.

Install it on macOS, Linux or Windows with one line, or with Homebrew. The compiler, runtime, SDK and docs are open source on GitHub under the BSD 3-clause licence: star it, read the docs, open an issue or send a pull request.

# macOS and Linux curl -fsSL https://riptidecompute.com/raya/install.sh | sh # Windows, in PowerShell irm https://riptidecompute.com/install.ps1 | iex # or with Homebrew brew install riptide-compute/tap/raya # write and run a program raya run main.ray # add a library raya add collection

Direct downloads with checksums, and every other install method for each system: Install. Check with raya --version.