# Ruby Playground

Run Ruby in your browser with a WASI runtime, prepared standard input, console output and coding examples.

## URL

https://ilham.dev/tools/ruby-playground/

## What It Does

Run Ruby 3.4 in a disposable browser Worker using ruby.wasm 2.10.1 and a WASI adapter. The runtime downloads from jsDelivr only on Run or when Auto-run is enabled. Exercises cover arithmetic, logic, arrays, classes and pyramid patterns. Code and input are not saved or uploaded by the tool. Ruby's JavaScript bridge can still access browser APIs and make requests; only run code you trust.

## Features

- Ruby WASI browser runtime
- Prepared standard input
- Run and Stop
- Coding exercises and pyramid patterns

## Input

Ruby snippet with optional prepared standard input ruby input.

## Output

Standard output, standard error and exceptions console output.

## Privacy

Processing happens locally in the browser.

No input data is uploaded to ilham.dev.

- Requires login: false
- Requires API key: false
- Stores user data: false


## Examples

- How do I read input?
- Why does the first Run take longer?
- Can I install gems or run Rails?
- Does selecting an example erase my code?
- Is this a security sandbox?


## Limitations

- Ruby WASM loads from jsDelivr on Run; the binary is approximately 16 MiB before compression.
- Prepared input is not a live interactive terminal; no gems are installed automatically.
- No native OS processes; a fresh Worker is created for each run.
- Worker execution is not a security sandbox; code can use browser APIs through the JavaScript bridge.
- Execution is limited to 30 seconds and 500 output rows.


## Related Tools

- https://ilham.dev/tools/python-playground/
- https://ilham.dev/tools/javascript-playground/
- https://ilham.dev/tools/typescript-playground/
- https://ilham.dev/tools/c-playground/
- https://ilham.dev/tools/cpp-playground/


## Questions

### How do I read input?

Fill Standard input before Run, one answer per line, then use STDIN.readline.chomp. Missing answers raise EOFError. This is prepared input, not a live terminal.

### Why does the first Run take longer?

The Ruby WASM binary is approximately 16 MiB before compression. It downloads from jsDelivr and initializes in a fresh Worker. Runtime loading has a 90-second timeout, followed by a separate 30-second execution limit. Normal HTTP caching can reuse assets between runs.

### Can I install gems or run Rails?

This runner provides a browser WASI build, not a desktop Ruby installation or a web server. No gems are installed automatically; arbitrary native extensions and OS subprocesses are unavailable.

### Does selecting an example erase my code?

No. It adds code above the existing snippet and pauses Auto-run. Clear first to run just the example. Ruby examples share the snippet's namespace, so later definitions can replace earlier ones.

### Is this a security sandbox?

No. A Worker prevents direct DOM access and can be terminated, but Ruby's JavaScript bridge can make network requests. The tool itself does not upload or persist code or input. Each Run starts fresh; output is limited to 500 rows.

