Experiments · Nobody Writes Code Anymore · Chapter 1
Borel’s monkey at the keyboard
The infinite monkey theorem
Everything is computed in your browser; nothing is sent anywhere.
About this experiment
What is the infinite monkey theorem?
The infinite monkey theorem says that a monkey hitting keys at random for an unlimited time will almost surely type any given text, the complete works of Shakespeare included. Émile Borel used the image in 1913. The catch is the time. The chance of a given string falls exponentially with its length: on a keyboard of 90 keys, even the twelve characters of return a + b take on the order of 10²³ attempts to come up by luck.
In 1913 Émile Borel imagined a blind monkey hitting the keys of a typewriter at random. Given enough time it would type anything at all, and the whole question is how much time is enough. The experiment sits the monkey at a keyboard of 90 keys and asks it for one short line of code, return a + b, twelve characters long.
Press “Let it type” and the browser produces a few hundred thousand random lines a second. Only the start of each line counts, because a line is lost at its first wrong key, so the counter shows the longest correct start so far and how many lines it takes on average to get one letter further. The first couple of characters come quickly. After that every extra letter costs ninety times as many lines as the one before it.
The lower half is the chapter’s sum. Every atom of the observable universe, about 10⁸⁰ of them, becomes a monkey typing a billion lines a second since the Big Bang, 13.8 billion years ago. Move the line-length slider and the verdict changes. The army gets through every possible line of about fifty-four characters and stops there. A program of a thousand hundred-character lines lies beyond that limit by nearly two hundred thousand orders of magnitude.
This is where the book starts. A language model also picks the next character at random, but its dice are weighted by all the code people have written. It is Borel’s monkey after reading the whole of GitHub. Vibe coding works because of that weighting plus a check at the end, and in vibe coding the check is one person looking at a screen.
From the book
Nobody Writes Code Anymore · Chapter 1
Random Code Programming
The weak point of both schemes, Borel’s and Koza’s, was randomness itself. The monkey presses every key with equal probability, and a mutation changes any symbol in a program with equal ease, so almost all the variants turn out to be garbage, and no amount of selection can cope with a mountain of garbage that size. If the monkey knew even a little about which letters usually follow which, things would go differently. If it had read everything humanity had typed before it, things would go very differently indeed.If this is your team
If agents write code on your team and every fix breaks something next to it, we can go through it on a call. The first consultation is free and takes thirty minutes.
Book a consultation →