How Nature Reuses Code

The original agile developer

Illustration by David S. Goodsell. This painting shows DNA being replicated in the nucleus. DNA polymerase is shown at the center in purple, with a DNA strand entering from the bottom and exiting as two strands towards the top. The new strands are shown in white.

Our CTO was always telling us to reuse code. If we built from scratch it usually came out months late, upside down and on fire. If we slightly modified something, we had working code within weeks. It was never perfect, but we could iterate on it and it got better.

This laziness is a core principle of agile development, though they call it something else — “simplicity: the art of maximizing the amount of work not done”. Nature just calls it evolution.

Biology is full of examples of code reuse, sometimes up to an absurd level. I’ll highlight three examples here. These aren’t obscure genetic functions. Without any of these three functions life as we know it would not exist. This code is effectively from the Linux kernel of life, and it’s hacky as hell.

1. The D1 Protein AKA ‘Turn It Off And On Again’

Shout out to purple nonsulfur bacteria

If your code crashes after 30 minutes you could just rebuild the entire server and start again. You wouldn’t, but you could. Nature does.

Before there was much oxygen in the world, purple bacteria figured out photosynthesis. Their nanomachine was highly stable unless there was oxygen around. Then it completely broke down. Did nature build new machinery that worked better in the new environment? Lol no. Nature just reused the code.

In these bacteria, the evolutionary ancestor of the D1 protein is highly stable, but in all photosynthetic organisms that produce oxygen, the protein is destroyed after it has processed about 10,000 electrons. “Destroyed” means it not only ceases to function, but it literally starts to fall apart. Effectively that takes about 30 minutes⁹⁷.

In programming terms, this would be as if you had some code that melts the server after 10,000 entries. Rather than changing the code, we just replace the whole server. This is insane but, you know, it works. I have called this turn it off and turn it on again, but it’s really worse than that. It turns it off, builds a new machine, and turn that on.

For a sense of perspective, photosynthesis is the root power supply for the entire living world. If you eat a burger, that was a cow, which ate plants, which got energy from the sun. If you drive a car, that uses oil, which was sea plants, which got energy from the sun.

All of life as we know it is powered by some code that we reused from purple bacteria. Code that catches fire every 30 minutes. It’s a wicked hack.

2. Nitrogenase AKA ‘Run It In A Virtual Machine’

Nitrogenase has to do a bit of Inception to work in an aerobic environment

If you really want to run Windows on a MacBook you can, you just set up a virtual machine. This pops up a new window with a different OS running. This is sorta like Inception inside your computer, except it’s slow and it sucks. Nature does this too.

Nitrogenase is a nanomachine that moves electrons and protons into nitrogen gas. It’s important, without this function we’d all be dead.

Like most of our kernel, nitrogenase runs on the old, anaerobic (no oxygen) operating system. The nanomachine contains iron, which rusts when it encounters oxygen. Rather than building something that runs natively on OS/2, nature just copied the old operating system and stuck it in a virtual machine. It continues to run the ancient code, in a severely degraded fashion.

In the oceans today, about 30% of all the nitrogenase is inactivated by oxygen at any one moment in time. That represents a lot of investment in a junkyard of used parts, which ultimately must be recycled to make new nanomachines⁹⁹.

No one would run a core function inside a virtual machine because it would be slow and inefficient, but nature is a more zealous agile developer than any of us. It insists on reusing the old nitrogenase code, inside a deeply leaky container.

3. Rubisco AKA ‘Just Add More Memory’

Our third and final nanomachine is Rubisco. Rubisco sounds like a biscuit company but is “arguably the most important biochemical reaction on Earth. It is the first step that leads to photosynthetic production of about 99% of the organic material upon which the rest of life depends⁹⁹.”

Rubisco is also buggy as hell. Around 30% of the time, it incorporates oxygen instead of CO2 and makes a worthless product. It is also really, really slow. Rubisco can only do 5 transactions per second, which is Bitcoin-level slow, much slower than everything else in the cell.

You would think that nature would rebuild a more efficient enzyme, but no, it just makes more of the crappy one.

While there have been minor improvements, the basic solution has been for cells to make a whole lot of the enyzme. That is a huge investment for a photosynthetic organism. It takes a lot of nitrogen to make Rubisco — nitrogen that could be put to better use to make new cells faster were it not for the inadequacies of the nanomachinery responsible for fixing carbon¹⁰⁰.

Like throwing more memory at bad code, nature just floods the zone. You can do this on a production server as well. If things are melting you can just keep adding more memory and accommodate whatever is going wrong, without actually fixing it. This is hugely expensive but again, nature is agile AF. Anything to reuse the code.

Nature The Agile Developer

I’ve mentioned these three examples because Paul Falkowski calls them the core genes. These are some of the key nanomachines that form the building blocks of life. This code is less than 0.025% of the genome, but it is by far the most important. The other 99.98% is specifics, how you make an orangutan, how you make a big butt, but these core genes are how you make life.

What this shows you is how important code reuse is in the natural world.

Rather than redesigning machines from scratch, nature recycles old machinery and slightly modifies it or develops a set of other components to help it function in a changing environment.¹⁰⁰

I find this fascinating because it’s almost exactly what that old CTO told me in relation to agile development. Reuse code. Iterate. Adapt. Evolve.

Nature obviously came first, but coming from an engineering world, it’s striking to see elements of the agile philosophy in the natural world. Early evolution really was a scrum and these little microbes, self-organized and iterated delivered some messy but amazing code.


This article is essentially a stupid version of the very excellent chapter Protecting The Core Genes in the book Life’s Engines by Paul G. Falkowski.