How Ruby Playground works
Static lesson pages run real Ruby in your browser.
Learning with examples
Each lesson asks you to predict output, run the code, change it, and explain the result. Editable examples and expandable answers let you compare your reasoning with the program's behavior.
The Ruby skill tree suggests prerequisites and practice goals. It separates available lessons from planned topics. It does not assess mastery or track progress. Start with Values if you are new to programming.
HTML, CSS, and JavaScript
Pages use HTML and shared CSS, with system monospaced fonts and a dark and a light theme. They follow your system setting until you use the Theme switch, which this browser remembers. The opening slides for the PhRUG talk are an exception: they carry their own inline styles and self-hosted brand fonts (Playfair Display, Figtree, and Geist Mono). The editors are native textarea elements; answers use details and summary. Small JavaScript files handle the Run, Stop, and Reset controls, the homepage's random lesson suggestion, and the Theme switch.
The site has no application build step, bundler, or JavaScript framework. Lesson text, code, answers, and the skill tree remain readable when JavaScript is disabled. Running Ruby requires JavaScript and access to the runtime downloads.
Ruby through WebAssembly
ruby.wasm brings CRuby, Ruby's standard implementation, to WebAssembly. This runner uses Ruby 4.0 and a JavaScript WASI adapter. It downloads the pinned @ruby/wasm-wasi@2.10.1 adapter and @ruby/4.0-wasm-wasi@2.10.1 runtime from jsDelivr. Browser caching may reuse those files.
- Run creates a new module Web Worker and sends it the editor's code.
- The worker downloads the adapter and Ruby WebAssembly file, then compiles and starts the Ruby virtual machine.
- Ruby evaluates the code while the runner captures standard output and standard error. The worker returns text to the page.
The page terminates the worker after each run, so the next run starts with fresh Ruby state. Stop cancels the active worker. Reset restores that example's original code and clears its output. Runs have a 30-second timeout; captured program output is capped at 16,384 bytes.
Ruby executes on your device through this runner. The site needs no Ruby execution server. The browser worker keeps Ruby work off the page's main thread; it is separate from the Cloudflare service that serves the site.
Deployment on Cloudflare
Cloudflare Workers Static Assets serves the site's HTML, CSS, and JavaScript at rubyplayground.org. The upload contains the reviewed files from public/, including _redirects. Repository files and tests stay outside that set.
Changes go through tests and independent review in a pull request. Merging to main deploys the site: Cloudflare Workers Builds runs Wrangler, which reads the repository's wrangler.jsonc and uploads public/. Manual releases can still upload the same files with cf deploy --prebuilt. Workers Builds does not check the live site itself, so live files and redirects are checked by hand after each merge deploys.
The Python test suite checks navigation, lesson structure, and the skill graph. It uses a Node.js harness for homepage behavior and native Ruby for lesson examples. Browser checks are separate and are needed to verify WebAssembly execution.