Folders
A program is a tree of empty folders. Names are ignored and files are ignored, so the whole program takes up zero bytes.
Daniel Temkin, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org
The idea
Daniel Temkin made Folders in 2015. The code is not in any file. It is in the shape of a directory tree: how many sub-folders each folder has, and in what order. Folder names can be anything, so a program can look like an ordinary, boring set of project folders.
Read the story
Because folders hold no data, a Folders program reports a size of 0 bytes, however large it is. It is camouflage at the level of the file system: nothing to read, nothing to scan, only structure.
An earlier dialect used folder names as commands. It was dropped; the current language reads structure only.
The machine
Folders are read in alphabetical order of their names. Each command is a folder whose first sub-folder says what it is (by its number of sub-folders) and whose later sub-folders hold the operands.
| Folders in the first sub-folder | Command |
|---|---|
| 0 | if (expression, then a folder of commands) |
| 1 | while (expression, then a folder of commands) |
| 2 | Declare a variable (type, name) |
| 3 | Let: assign (variable, expression) |
| 4 | Print (expression) |
| 5 | Input (variable) |
Expressions work the same way:
| Count | Expression | Count | Expression |
|---|---|---|---|
| 0 | Variable | 5 | Literal value (type, then value) |
| 1 | Add | 6 | Equal to |
| 2 | Subtract | 7 | Greater than |
| 3 | Multiply | 8 | Less than |
| 4 | Divide |
Types: 0 int, 1 float, 2 string, 3 char. A literal value is written in hexadecimal: each hex digit is a folder of four folders, where a folder that contains a sub-folder is a 1 bit and an empty one is a 0 bit.
Example
The shape of a program that prints one character, drawn as a tree.
The shape of a program that prints one character, drawn as a tree. Names are placeholders, chosen so that alphabetical order is the order shown:
prog/
a/ one command
a/ [a b c d] 4 folders: print
b/ the expression
a/ [a b c d e] 5 folders: a literal value
b/ [a b c] 3 folders: of type char
c/ the value, hex digits in order
... groups of four folders, full = 1, empty = 0
This is illustrative. The specification does not fully pin down the bit order inside a group, or how many hex digits a char takes, so check the reference implementation before building one by hand.
A program that builds this tree with a script, then runs it, is the honest way to work: nobody writes Folders by clicking "New folder".
Patterns it teaches
- Camouflage: the program does not look like anything, because it has no content. The only "text" is a shape.
- Encoding tricks: a tree of counts, with bits written as "has a child" or "has none". It is Unary-like in spirit: the number of things is the message.
Try this
- Draw the tree for a
whileloop whose body prints a variable. - Write a small Node script that turns a nested list like
[4, [5, [3], [...]]]into real folders. - Hard: write a Folders interpreter that reads a directory tree. (
fs.readdirSyncand a sort are most of the work.)
Further
- esolangs.org/wiki/Folders
- Daniel Temkin's page on Folders: danieltemkin.com/Esolangs/Folders
- The reference implementation (C#): github.com/rottytooth/Folders
See also
Non-textual
Source esolangs.org (CC0) · Edit on esolangs.org