esolang
Learn · Ideas149 languages show it

Camouflage

Programs that look like something else, such as a play, a recipe, a power ballad, a painting, a folder tree. The code hides in plain sight.

●○○ easy · where to see it

The idea

A camouflage language makes its programs pass for another kind of text. The program is a valid example of the disguise (a recipe you could almost cook, a play you could almost stage) and a valid program. Getting both at once is the art.

Read the story

There are two strategies.

  • Use the surface, ignore the content. Most of the text is decoration; only some feature carries the meaning. In Rockstar the length of each word can be a digit. In Piet only the changes between colours matter. In Folders (Daniel Temkin) only the structure of nested, empty folders does.
  • Make the content the code. In Shakespeare (Karl Hasselström and Jon Åslund, 2001) characters are variables, acts and scenes are labels, and insults are negative numbers. In Chef (David Morgan-Mar) ingredients are variables and mixing bowls are stacks.

A special case is camouflage inside other code. Whitespace (Edwin Brady and Chris Morris, 2003) uses only spaces, tabs and newlines, so a Whitespace program can be hidden in the indentation of a C or Python file. That is steganography.

How it works

Rockstar (Dylan Beattie, 2018) has poetic number literals.

Rockstar (Dylan Beattie, 2018) has poetic number literals. After is or was, each word gives one digit, its length mod 10.

Tommy was a lean mean wrecking machine
Wordaleanmeanwreckingmachine
Letters14487

So Tommy holds 14487. A lyricist writes a line; the computer reads a number. Any number can be written in any style, as long as the word lengths are right.

Shakespeare counts differently. A noun is 1 (or −1 if it is an insult), and every adjective in front doubles it. "A big big cat" is 4. "A stinking pig" is −2. A character told "You are as good as a big big cat" now holds 4.

The general recipe.

  1. Pick a genre with a lot of freedom (lyrics, recipes, drama, music).
  2. Find one feature the author must control anyway (word length, adjective count, pitch, colour).
  3. Let that feature carry the program, and leave everything else free.

The numbers

One set of 118 esolangs.org languages, each with a description exact enough to implement and check, holds…

One set of 118 esolangs.org languages, each with a description exact enough to implement and check, holds 89 brainfuck substitutions, 10 Deadfish substitutions and 19 languages with semantics of their own.

A substitution keeps the machine and changes only the spelling. A table says which token means +, which means >, and so on. Making one takes a minute, so there are many. esolangs.org keeps a list of them.

The same program in other clothes

!!Fuck, with each brainfuck command written as its token.

!!Fuck

!!Fuck, with each brainfuck command written as its token.

Expected output

Hello World!

Output


Hanzifuck

Hanzifuck, with each brainfuck command written as its token.

Expected output

Hello World!

Output


Morsefuck

Morsefuck, with each brainfuck command written as its token.

Expected output

Hello World!

Output


What breaks a substitution

Each substitution, as a kernel dictionary, ran 21 brainfuck programs, each in four spellings (as written, glued together, with English prose between tokens, and in capitals). Languages that behave the same on all of them form one cluster. The brainfuck family splits into 18 clusters.

The largest behaviour clusters of the brainfuck family
LanguagesBehaviour
42behaves as brainfuck in every spelling
34behaves as brainfuck except in capitals (21 of 21 wrong)
1behaves as brainfuck except with English prose between tokens (12 of 21 wrong), in capitals (21 of 21 wrong)
1behaves as brainfuck except with English prose between tokens (10 of 21 wrong)
1behaves as brainfuck except with English prose between tokens (11 of 21 wrong)
1behaves as brainfuck except in capitals (16 of 21 wrong)

What breaks a substitution is always the spelling, never the machine.

  • Capitals. A case-sensitive token like Ook. is not read in OOK..
  • Prose between tokens. If a token is an English word, the prose around it contains it too.
  • Gluing. Tokens that are prefixes of each other, like f and f(), are read differently without spaces. The reader always takes the longest match.

Why they are still useful

For a machine that learns to read, substitutions are ideal examples.

For a machine that learns to read, substitutions are ideal examples. The machine is known and only the reading is new. A language that knows brainfuck can learn a substitution by learning its words, and the transfer can be measured. See learning to read.

Try this

  1. Write a Rockstar line that sets a variable to 2026.
  2. In Shakespeare's rule, how many adjectives do you need in front of a noun to make 64?
  3. Hard: take a short Python file and hide a Whitespace program in its trailing spaces. Both must still run.

Seen in

  • Shakespeare. Programs as plays.
  • Chef. Programs as recipes.
  • Rockstar. Programs as rock lyrics.
  • LOLCODE. Programs in the voice of internet cat captions.
  • Piet. Programs as abstract paintings, after Piet Mondrian.
  • Velato. Programs as music; notes are read relative to a root note.
  • Folders. Programs as empty folders on disk.
  • Whitespace. Programs hidden in blank space.
  • Chicken, Ook!. One word, repeated; camouflage as a joke.

Further

Where to see it