MCV
A programming language from the impossible library.
Jorge Luis Borges, "The Library of Babel" (1941); trans. James E. Irby"One which my father saw in a hexagon on circuit fifteen ninety-four was made up of the letters MCV, perversely repeated from the first line to the last.
…four hundred and ten pages of inalterable MCV's cannot correspond to any language, no matter how dialectical or rudimentary it may be."
The narrator in Borges' story is wrong, of course. I knew it as soon as I read the words. If you're familiar with programming languages you probably had the same reaction. You can encode an arbitrary program with just two characters, so three is luxurious. Later on in the story the librarians make a guess that each letter might influence the next, while others guess that the MCVs compose a cryptograph. Feeling badly for them, I've designed a decoder:
The decoder is named MCV. It's a stack-based, Turing-complete programming language whose source code consists only of the letters M, C, and V. Per my reading of Borges, there are no spaces, no punctuation, no line breaks included, so the script is a single unbroken string of three letters. Here is a complete program that adds 5 and 3 and prints the result:
MMMCMCVMMMCCVCMMMCVMCVVV
That outputs 8. The book is interpretable!
Watch it run
An MCV program is one unbroken string of three letters. The interpreter reads it left to right: each run of letters is a single instruction that pushes, pops, or prints. Step through one below — every instruction lights up, splits into its parts, and moves the stack.
MMMCMMCMMMVCVMMMMMCCMMCMCVCVMMMMMCCMCCMMVCVMMMMMCCMCCMMVCVMMMMMCCMCCCCVCVMMMMMCMCCMMVCVMMMMMCMMMMMVCVMMMMMCMCMCCCVCVMMMMMCCMCCCCVCVMMMMMCCCMMCMVCVMMMMMCCMCCMMVCVMMMMMCCMMCMMVCVMMMMMCMMMMCVCVMMMMMCMCMVCVMMVVV
Push 72 onto the stack
Stack
Output
step 0 / 29
Every MCV program already exists as a book in the Library of Babel. Find this exact one →
Provenance
We don't so much write MCV scripts as find them. Every valid MCV program already exists as a book in the Library. You can verify this yourself: paste any of the MCV scripts from the interactive tool above into the search box at libraryofbabel.info — Jonathan Basile's working implementation of the Library — and it will hand you the hexagon, wall, shelf, and volume where that book has been waiting for the MCV language to be invented.
One extra flourish
The instruction for discarding a value from the stack encodes as the literal string MCV. In other words, the language's name is also an instruction in the language to throw something away. This was a totally accidental result of the encoding scheme, but it felt like kismet. The IMP prefix for stack operations is M, and the opcode for discard is CV, which concatenates to MCV. I thought that was cute!
The language
MCV is implemented in Python, has no dependencies, and is on GitHub. It ships with a small assembler so you can write in human-readable mnemonics and compile down to the wall of letters.
The architecture is adapted from Whitespace, a 2003 esolang by Edwin Brady and Chris Morris that uses space, tab, and linefeed as its three symbols. Whitespace proved the thing could be done. MCV gives it a different instruction set, a Borgesian premise, and a worse name.
