Easy
Brainfuck typed in while it runs. The program reads its data from the same place it reads its code.
2005 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Easy, from 2005, is brainfuck in which all the code is written at run time. Hence the author's joke that it is extremely easy to write programs in Easy. The interpreter reads its input one command at a time, or a whole [ ... ] block at a time, and runs what it read. Data comes from the same input. A . reads the next character, whatever it is, so the data sits in the program right where it is read.
Read the story
The commands are brainfuck's, with input and output switched. A character that is not one of the eight commands ends the program at once, and so does the end of the input.
The machine
| Command | Does |
|---|---|
+ - | Add 1 to the cell; take 1 off |
> < | Move right; move left |
[ ] | Loop while the cell is not 0; a block is read whole before it runs |
. | Read the next character of the input into the cell |
, | Print the cell |
The source is the start of the input, and anything given with --input follows it. The specification leaves the machine open. Cells are bytes that wrap, the tape has no end either way, and . reads 0 at the end of the input.
Example
The third Hello world in the specification.
The third Hello world in the specification. Each . reads the letter after it and each , prints it. As written it has no space.
The quine by MizardX is the same half twice. The first half runs as one block. Its . reads the second half as data and prints it, then it walks back along the tape and prints it again.
The input goes on where the source stops, so a program can find its data there. This cat enters its block with +, reads a character, and then prints and reads until it reads the 0 at the end.
The second Hello world, +[.,]Hello, world!, reads and prints in a loop until the input runs out. The 0 it reads at the end is printed too, before the loop stops, so its output ends in a zero byte.
The specification also has a C interpreter. As its own comment says, it is not the spec. It switches . and , back to brainfuck's and passes over other characters. The first Hello world is plain brainfuck and runs only there.
Patterns it teaches
- Turing tarpit: brainfuck's eight commands, fed in one at a time.
- Code as data: the program and its data are one stream of characters.
- Quine: a program that reads its own second half as data.
Further
See also
Easy builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Easy
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: easy.
Command line
shib run easy -e '+[.,]Hello, world!'shib manual easySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/easy.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org