Chris Collins

Lab

The Lab is for exploring: learning how something works by running it — walk-throughs built around live simulations, code you can edit and run in your browser, small sketches, and the same program in many languages. Tools are for getting a job done; the Lab is for poking at ideas and seeing what happens.

Explorations

Guided experiments: a question, live tools and code to try, and what the results show.

Exploration ·

How a brushless motor spins

How things work · part 2

From magnets and coils to a quadcopter in the air: how a brushless motor is wound, how an ESC switches it in six steps, how it finds the rotor without sensors, what field-oriented control does better, and what happens when you bolt four of them to a frame — with the simulators running alongside.

Brushless motors — inside and how they are drivenRC power setup — motor, prop and batteryFPV quad: build, rates, CLI diff and blackboxPID loop simulator

Exploration ·

How a database survives a crash

How things work · part 3

Pull the plug on a database halfway through a write and it comes back with every committed transaction and none of the half-finished ones. How? Follow a write through the log, the buffer pool and the disk, compare B+trees with LSM-trees, watch compaction, and then see the other half of the promise — what concurrent transactions are allowed to see — with real PostgreSQL and SQLite running between the paragraphs.

Postgres playgroundStorage engines: LSM-tree vs B-tree, simulatedSQLite internalsIsolation lab

Exploration ·

How the Amiga drew Boing

How things work · part 5

A red and white ball bouncing across a purple grid sold a computer. Take it apart with live tools — the copper and the beam, colour cycling, sprites and blitter objects, the cookie-cut blit, the fight for chip RAM, and Paula's boom — and see how a 7 MHz machine made it look effortless.

Shader playgroundCopper and blitter playgroundAmiga sprites and BOBsAmiga blitter labAmiga DMA slot timingPaula audio, MOD tracker and player

Exploration ·

How web search works

How things work · part 6

Follow a query from the box you type it into to the ten blue links: how text becomes terms, how an inverted index stores and compresses them, how BM25 scores a match, how we know a ranking is any good, and how the whole thing is split across thousands of machines — with the tools running live between the paragraphs.

Analyzer and inverted-index playgroundPostings labRelevance and scoring explainerRanking metrics workbenchElasticsearch, simulatedSystem design interviews

Playgrounds

Pages of code to edit and run, by language.

Playground

A JavaScript playground

Edit the code and run it in your browser — a quick demonstration of the site's playgrounds.

JavaScript · Python · HTML

Playground

BQN playground

BQN, a modern APL, in your browser — whole-array primitives, folds and scans, tables, and tacit trains like (+´÷≠) for the mean.

BQN

Playground

C and C++ in the browser

Real Clang, compiled to WebAssembly, building and running C and C++ programs entirely inside your browser.

C · C++

Playground

Clojure playground

Clojure in your browser through Scittle — immutable data, lazy sequences, transducers, threading macros, atoms, and multimethods.

Clojure

Playground

Esoteric languages: Brainfuck and Befunge

Two famous esoteric languages to run in your browser — Brainfuck's eight commands on a byte tape, and Befunge's program counter wandering a 2-D grid.

Brainfuck · Befunge

Playground

Forth playground

A small Forth that runs in your browser — the data stack, defining new words, loops, and memory, in the language that fits in 8 KB.

Forth

Playground

Fortran playground

Modern Fortran compiled in your browser by LFortran — whole-array arithmetic, matrix intrinsics, modules and derived types, and a numerical kernel solving the heat equation.

Fortran

Playground

Kotlin playground

Edit Kotlin here and JetBrains' Kotlin Playground compiles and runs it — data classes, null safety, sealed types with when, extension functions, sequences, and coroutines.

Kotlin

Playground

Lua playground

Lua 5.4 running as WebAssembly — coroutines, metatables, and string patterns you can edit and run.

Lua

Playground

OCaml playground

The OCaml 5 toplevel in your browser — type inference, pattern matching, variants, records, and modules with functors.

OCaml

Playground

Perl playground

Perl 5 running as WebAssembly in your browser — regular expressions, hashes, text munging, and the context rules that make Perl Perl.

Perl

Playground

PHP playground

PHP 8.4 running as WebAssembly in your browser — its do-everything arrays, the string library, match, enums, readonly classes, and generators.

PHP

Playground

Prolog and Scheme playground

Logic programming with SWI-Prolog compiled to WebAssembly, and Lisp-family functional programming with Scheme — both live in the page.

Prolog · Scheme

Playground

R playground

Real R running in your browser through webR — vectors, data frames, a linear model with its summary, simulation, and base-graphics plots.

R

Playground

Retro BASIC playground

Classic line-numbered BASIC, the way the 8-bit machines did it — PRINT, INPUT, GOTO, GOSUB, and a lunar lander to fly.

BASIC

Playground

Ruby playground

CRuby 3.4 with its standard library, running as WebAssembly — blocks, Enumerable, pattern matching, and Data classes.

Ruby

Playground

Rust and Go playground

Edit Rust and Go here; they are compiled and run by the official Rust and Go playgrounds, with the output shown in the page.

Rust · Go

Playground

SQL playground: SQLite and DuckDB

Two real database engines compiled to WebAssembly — SQLite for everyday SQL and DuckDB for analytics on your own CSV and Parquet files.

SQLite · DuckDB

Sketches

Small visual experiments: shaders, generative drawings, canvas toys.

Playground

A generative melody box

A WebAudio toy that improvises a melody with a random walk over a pentatonic scale, plus a drone and an echo — silent until you press Play.

HTML

Playground

A harmonograph drawing machine

Four decaying pendulums steer a pen; frequencies near simple ratios draw the spirograph-like curves Victorian harmonographs were famous for.

p5.js

Playground

A raymarched scene

A whole 3-D scene — a blobby shape on a checkered floor, soft shadows, an orbiting camera — drawn by one fragment shader with no triangles at all.

GLSL

Playground

Boids

Craig Reynolds' flocking model — three local rules per bird, and a flock emerges; the mouse is a predator.

p5.js

Playground

Flow fields

Thousands of particles drifting through a Perlin-noise vector field, leaving trails that pile up into silk.

p5.js

Playground

L-system plants

A few rewriting rules and a turtle grow a meadow of plants that are never quite the same twice.

p5.js

Playground

Life with colour trails

Conway's Game of Life where live cells are coloured by age and dead ones leave a fading ghost, so you can see where the action has been.

p5.js

Playground

Reaction–diffusion

The Gray–Scott model — two imaginary chemicals that spread and react — grows coral, fingerprints and dividing cells from a few drops.

HTML

Rosetta

Same program, many languages — one task written side by side, each runnable.

Playground

A tiny JSON parser in thirteen languages

A recursive-descent JSON parser and pretty-printer, written from scratch in thirteen languages — how each one represents "a value that could be anything", reports errors, and handles strings, escapes and Unicode.

JavaScript · Python · Ruby · Lua · PHP · Perl · Clojure · C · Rust · Go · Kotlin · OCaml · Prolog

Playground

FizzBuzz in nineteen languages

The smallest interesting program, written the way each language would write it — from JavaScript and Rust to SQL, Prolog, BQN, Forth and a Befunge maze. Every block runs and prints the same twenty lines.

JavaScript · Python · C · Rust · Go · Kotlin · Ruby · Lua · PHP · OCaml · Clojure · Scheme · Prolog · SQLite · R · BQN · Forth · BASIC · Befunge

Playground

N-body: a small solar system, timed

The same five-body gravity simulation in fifteen languages, each timing itself — a hands-on look at how much the runtime matters when the program is all floating-point arithmetic in a tight loop.

C · C++ · Fortran · JavaScript · OCaml · Clojure · Python · Ruby · Lua · PHP · Perl · R · Rust · Go · Kotlin

Playground

The Mandelbrot set as ASCII art

Nested loops and floating-point arithmetic in eighteen languages — plain loops, complex numbers, whole-array versions in R and BQN, and a recursive query in SQL — all drawing the same 66 × 23 picture, character for character.

JavaScript · C · Rust · Go · Kotlin · Lua · Ruby · PHP · Perl · Python · C++ · Fortran · R · BQN · OCaml · Clojure · SQLite · BASIC

Playground

Word frequency in fifteen languages

Count the words in a paragraph and list the ten most common — split, count, sort — in fifteen languages, from one-line pipelines in Ruby and Clojure to a hand-rolled hash table in C and a recursive string split in SQL.

JavaScript · Python · Ruby · Clojure · Kotlin · R · Perl · PHP · Lua · OCaml · C · Rust · Go · SQLite · DuckDB

Notebooks and sandboxes in Tools

Open-ended tools that live under Tools but are made for experimenting.

DuckDB analytics labReal DuckDB in your browser with a console, results grid, plan trees for EXPLAIN ANALYZE, quick charts and CSV/Parquet export — sample datasets, your own CSV/Parquet/JSON files read locally, and twelve guided labs: window functions, QUALIFY, PIVOT, ASOF joins, ROLLUP/CUBE, nested types, regex, Parquet metadata and columnar storage.Language sandboxWrite and run code in 29 languages — JavaScript, TypeScript, Python, Java, Kotlin, C, C++, Rust, Go, R, PHP, Perl, Ruby, Lua, OCaml, Fortran, Clojure, Scheme, Prolog, BQN, Forth, BASIC, SQLite, DuckDB, HTML, p5.js, GLSL, Brainfuck and Befunge — and share it as a link.Postgres playgroundReal PostgreSQL 18 in your browser (PGlite) with a psql-like console, twenty runnable labs for the distributed patterns Postgres does well — SKIP LOCKED queues, advisory-lock mutexes, leases with fencing tokens, leader election, LISTEN/NOTIFY, outbox, idempotency keys, rate limits — an animated model of concurrent sessions, and a real-server mode that races sessions on your own Postgres.Python notebookA Jupyter-style Python notebook that runs entirely in your browser (Pyodide) — code and Markdown cells, one shared namespace, pandas tables and matplotlib figures inline, tracebacks, CSV upload, open and download .ipynb files, autosave, share links, and starter notebooks for pandas, plotting, linear algebra, SciPy statistics and simulation.React render labReal React 19 running your component on the page, with a live component tree that flashes on every render and says why — which state, which props, which context, or just the parent — render counts and times, a commit timeline, the console, and eleven lessons from lifting state to Suspense, use() and the React Compiler.Shader playgroundWrite GLSL fragment shaders and watch them run as you type — WebGL2 with a WebGL1 fallback, compile errors on their lines, Shadertoy's iTime/iResolution/iMouse/iFrame, sliders and colour pickers for your own uniforms, pause, step and scrub, PNG and WebM export, .frag export for Shadertoy, glslViewer and other hosts, share links, and nine examples with lessons from UV gradients to raymarching and a Boing ball.Tailwind CSS playgroundWrite HTML with Tailwind classes and see it live — Tailwind 4's browser build in a sandboxed preview, your own theme and utilities, a dark-mode switch, phone / sm / md / lg / xl preview widths, a class inspector that explains every utility and shows the CSS it generated, six components to start from, and exports with the CDN or compiled CSS.TypeScript playgroundThe real TypeScript 6 compiler in your browser — errors with line, column and TS code as you type, hover types, the emitted JavaScript and .d.ts, every strictness flag, a tsconfig.json explained option by option, advanced-type examples, and Run in a sandboxed page or a worker.