PlayPlayground
Playground
Start with
Interpreter: the classic one.
Play the program
Printed
What the program is doing
- State
- Ready
- Steps so far
Program
Every character that is not one of + − < > [ ] . , is a comment. Tab leaves the editor. Click left of a line, or press F9, for a breakpoint.
Tape
The tape in words
Input
Input options
Text is sent as UTF-8 bytes. A change takes effect at the next Start again, or when Play starts from the beginning.
Printed
Nothing printed yet.
Tools
Choosing an example replaces the program, the input and the cell names. Undo brings your program back.
Worked out from the text of the program, without running it.
Link
The link holds the program, the input, the settings, the cell names and the breakpoints, compressed in the part after the #. Nothing is sent to a server.
Saved in this browser
Files
You can also drop a file anywhere on this page. Files up to 64 MB are accepted. Up to 300,000 characters a program can be edited (with colours up to 150,000); a larger one is kept as it is and can be run, stepped and analysed, but not edited.
What the page shows
The interpreter
Interpreters differ in these points, and a program can depend on them. A change resets the program.
Write a brainfuck program, run it, and step through it forward and back. The tape shows every cell, and one sentence says what each command does.
The eight commands
> | move the pointer one cell to the right |
|---|---|
< | move the pointer one cell to the left |
+ | add 1 to the cell under the pointer |
- | take 1 from the cell under the pointer |
. | print the cell as one character |
, | read one byte of input into the cell |
[ | if the cell is zero, jump past the matching ] |
] | if the cell is not zero, jump back to the matching [ |
Everything else is a comment. The tape starts with every cell at zero and the pointer on cell 0.
Keyboard
- Ctrl + Enter or F8
- Play, or pause when playing
- F10 or Ctrl + .
- Step
- F7 or Ctrl + ,
- Step back
- F2
- Step over a loop
- Shift + F2
- Finish the loop you are in
- F4
- Play to the text cursor
- Shift + F8
- Start again
- Ctrl + Shift + Enter
- Play fast
- Esc
- Pause, or stop a fast run
- F9
- Breakpoint on the line of the text cursor
- Ctrl + Z, Ctrl + Y
- Undo and redo in the editor
- Tab, Shift + Tab
- Leave the editor: Tab is never caught, so the keyboard cannot get stuck in it
- ← → on the tabs
- Next and previous tab of this panel
On a Mac, use ⌘ where this list says Ctrl; the function keys may need fn.
Playing and stepping
- Play works in the page, at the speed of the slider, and stops at breakpoints. Step back takes back up to 200,000 steps; older steps are forgotten.
- Play fast works in the background with an optimising interpreter. It ignores breakpoints. Stop ends it at once, whatever the program is doing; Pause and inspect hands the program to the debugger where it stands.
- Breakpoints. Click left of a line (or F9). A run pauses when it arrives at that line from another line. The breakpoint character (Settings) pauses wherever it stands; common interpreters use
#or!, and here you choose which, or none. - Input. The comma reads bytes from the input box. When the box is used up, the program either asks you or gets the end of input: 0, −1 or no change, as set.
- Cells. Press a cell to give it a name or change its value. Names are saved with the program and in the link.
- The program map. The strip beside Steps so far is the whole program from its first command to its last. Its height is the loop depth, and the block marks the command that runs next.
Use it in another page
A small version of the playground can be put in any page of this site: see the instructions in embed.js and an example.
The rest of the site
This page is one screen, so it has no footer. Every page of the site is in the sitemap.