Chicken
The only word is "chicken". The number of chickens on a line is the instruction, and the code lives on the same stack as the data.
Torbjörn Söderstedt, 2013 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Torbjörn Söderstedt made Chicken in 2013. It was inspired by a famous joke paper by Doug Zongker, "Chicken Chicken Chicken: Chicken Chicken", a complete scientific paper (and talk) in which every word is "chicken".
Read the story
The disguise is total: a program is lines of chicken chicken chicken. Underneath is a small stack machine. Each line's count of chickens is one opcode. The count is unary: a line of 75 chickens means "push 65".
The deeper trick is where the code goes. The program is loaded onto the same stack it computes on. So the machine can read, overwrite and jump into its own code.
The machine
The stack starts with two registers, then the code, then free space:
| Cell | Holds |
|---|---|
| 0 | A reference to the stack itself |
| 1 | The user input (a string) |
| 2, 3, … | One cell per line: its chicken count. Then an extra 0 (exit) |
| after that | The working stack |
Execution starts at cell 2. Values behave like JavaScript values, as in the original implementation.
| Chickens | Name | Does |
|---|---|---|
| 0 | axe | Exit. An empty line is 0, so blank lines matter |
| 1 | chicken | Push the string "chicken" |
| 2 | add | Pop b, a; push a + b (strings concatenate) |
| 3 | fox | Subtract |
| 4 | rooster | Multiply |
| 5 | compare | Push whether a == b |
| 6 | pick | Double-wide: the next cell picks a source (0 = stack, 1 = input); pop an index and push that item |
| 7 | peck | Pop an address, pop a value, store it there |
| 8 | fr | Pop an offset, pop a condition; if true, jump by the offset |
| 9 | BBQ | Pop x, push the HTML entity &#x; |
| 10+ | push | Push the number (count − 10) |
When the program exits, the top of the stack is printed, after HTML-unescaping (so A prints A).
Example
The shortest program is one line: chicken.
The shortest program is one line: chicken. It pushes "chicken", exits, and prints chicken. It is a quine by accident of design.
Adding two numbers: a line of 12 chickens (push 2), a line of 13 (push 3), and a line of 2 (add). The result, 5, is on top when the program exits.
The last line uses MiniChicken notation, one number per line, from the esolangs page. It reads digit 0 of the input (push 0, pick from source 1), turns "1" into a number by subtracting 0, does the same for digit 2, and adds them. The 60-line Hello World from the esolangs page also prints Hello world in this implementation.
Patterns it teaches
- Camouflage: a program that is one word repeated. Compare Ook!, which disguises Brainfuck as orangutan noises.
- Encoding tricks: the opcode is a unary count per line.
- Code as data and self-modifying code: the code is cells on the stack, so
peckcan rewrite it andfrcan jump into pushed data. - Quine:
chickenprintschicken. A cheap quine, because output is just "whatever is on top". - Stack machines: a minimal one, with the program inside it.
Try this
- Write a Chicken program that prints
7(17 chickens on one line). - Use
BBQto print the letterA. How many chickens is the longest line? - Hard: write a loop with
frthat counts down from 3. You will needpickandpeckon the stack cells just above the code.
Further
- esolangs.org/wiki/Chicken
- The original site and JavaScript implementation (archived): torso.me/chicken
- Doug Zongker, "Chicken Chicken Chicken: Chicken Chicken": isotropic.org/papers/chicken.pdf
See also
Non-interactive IO
Self-modifying
Write your own in Run Convert a program from Chicken
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: chicken.
Command line
shib run chicken -e 'chicken'shib manual chickenSource
- Module
langs/museum/ports.js- Interpreter
langs/museum/chicken.js,langs/museum/push.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org