Lenguage
Only the length of the file matters. Every text of exactly 23,855 characters, whatever it says, is the same cat program.
Pietu1998, 2014 · Turing complete: with unbounded memory · ●○○ easy · esolangs.org
Tested with 1 known program · Test method
Run it
The idea
Unary says: a program is a number of zeros. Lenguage, made in 2014 by the esolangs.org user Pietu1998 after a code golf challenge, drops the zeros. Any characters will do. The file's length is the program; its content is ignored completely.
Read the story
So a short story cut to that length and 23,855 copies of the letter x are one and the same program. You can hide a Lenguage program inside any text by trimming or padding it to the right length.
It is a joke about encoding tricks taken as far as it goes: the "code" carries no information at all, except how much of it there is.
The machine
Brainfuck's machine. To find the Brainfuck program inside a file of N characters:
- Write N in binary.
- Pad it on the left with zeros until its length is a multiple of 3.
- Read it three bits at a time:
| Bits | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
|---|---|---|---|---|---|---|---|---|
| Brainfuck | + | - | > | < | . | , | [ | ] |
The table is not Unary's, and there is no marker bit. That has a cost: leading zeros vanish when a number is written, so a program cannot start with +. Start with something else (a harmless ><, say) and the +s survive.
Example
cat is ,[.,]:
cat is ,[.,]:
101 110 100 101 111 , [ . , ]
= binary 101110100101111 = 23,855
Any file of exactly 23,855 characters is cat.
node -e "require('fs').writeFileSync('cat.len', 'x'.repeat(23855))" && shib run lenguage cat.len --input meow
The leading-+ problem. Encode ++++++++[>++++++++<-]>+. (prints A) and decode it again, and the first eight +s are gone. Write >++++++++[<++++++++>-]<+. instead and it works:
Patterns it teaches
- Encoding tricks: the program is a number, and the file is the laziest possible way to write that number.
- Every text runs: every file of every length is a valid program (as long as its Brainfuck has balanced brackets). But in Lenguage that is trivial, because content does not matter.
- Turing completeness: as powerful as Brainfuck, and as useless in practice as Unary.
Try this
- What does a 1-character file do? A 7-character one? Work it out, then check with
-n. - Find the shortest Lenguage program that prints something.
- Take a text you like and work out how many characters you must add or cut to make it print
A.
Further
- esolangs.org/wiki/Lenguage
- Its parent: Unary. The language underneath: Brainfuck.
See also
Lenguage builds on Brainfuck.
Brainfuck equivalents
Cell-based
Write your own in Run Convert a program from Lenguage
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: lenguage.
Command line
shib run lenguage program.txt --input 'meow'The program is long; save it as program.txt first.
shib manual lenguageSource
- Module
langs/museum/ports.js- Interpreter
langs/museum/lenguage.js,langs/common.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org