Free

1: The World of Programming Around Us

⏱️ 35-50 minutes
📊 beginner

Chapter 2: "Programs of Nature"

Alice, Professor Bit, and Byte settled on a lawn in the park. It was a warm spring day, and life was bustling around them.

— Alice, did you complete the task with commands for Byte? — asked the Professor, laying a small microscope on the grass.

— Yes! — the girl replied joyfully. — Though at first I got something strange instead of a square. I forgot to specify how many steps Byte should move.

Professor Bit nodded:

— Great observation! In programming, it's very important to be precise. But you know, not only people write programs. Look around — nature is full of programs that have been working for millions of years!

— Nature? — Alice was surprised. — But there are no computers and programmers in the forest.

Logic, who was sitting on a branch of the nearest tree, flew down lower:

— In nature, programs are written not in computers, but in DNA — molecules that exist in every living cell. DNA contains instructions for everything alive.

The Professor pulled a small projector from his pocket, and an image of a double helix appeared on a white sheet.

— This is DNA, — he explained. — Imagine it's a huge recipe book. It contains what color your eyes will be, how your heart is structured, and even when flowers should open their petals!

Byte suddenly perked up and pointed to a group of ants moving in a chain:

— Look! The ants are following a program!

Alice crouched down to get a better look at the little workers:

— They're all following one path. As if someone drew them a line.

— Well noticed, — said the Professor. — Ants follow a simple algorithm. When a scout ant finds food, it returns to the anthill, leaving behind a special smell — a pheromone. Other ants sense this smell and follow it. The more ants that pass along the path, the stronger the smell and the more ants sense it.

— It's like... a loop! — Alice guessed. — The more ants go along the path, the stronger the path becomes, and the more ants go along it!

— Exactly! — the Professor was pleased. — Nature uses loops, conditions, and other techniques we find in programming.

Logic pointed her wing at a passing flock of birds:

— Look at those birds. Why do you think they fly in a V-formation?

Alice shrugged:

— Probably it's more convenient for them?

— Correct, — Logic nodded. — This formation helps them save energy. Each bird, except the leader, flies in an upward air current created by the bird in front. When the leader gets tired, it gives way to another. It's like a program with task rotation.

Professor Bit pulled a small pine cone from his bag:

— Here's another example of natural programming. Do you see the pattern on the cone? These aren't random lines. The cone scales are arranged in a spiral, and the number of these spirals always corresponds to Fibonacci numbers — a special mathematical sequence.

— Fibonacci what? — Alice asked again.

— Fibonacci, — the Professor repeated. — It's a sequence of numbers where each next number equals the sum of the two previous ones: 1, 1, 2, 3, 5, 8, 13... Nature uses this sequence everywhere — in the arrangement of flower petals, tree branches, even in the shape of galaxies!

Byte picked up an autumn leaf from the ground:

— What about trees? Do they also follow a program?

— Of course! — confirmed the Professor. — Every autumn, leaves change color and fall, and in spring new ones grow. This is a seasonal cycle. And inside the tree there are conditional algorithms: "IF there's little water, THEN drop some leaves to reduce evaporation."

Alice's eyes widened:

— So all of nature works like a huge computer!

— In a way, yes, — the Professor agreed. — Only nature "programmed" its creations over millions of years through evolution.

The Code of Life

In the beginning — chaos, burst and thunder,

A water body boiling under fire.

But in this flame and gloom

A code was born in living earth.

In a spiral twisted like a thread,

It learned to be and live.

In patterns of waves, in rings of winds,

In a sprout reaching without words.

Errors? Only at first glance —

They forge the fragile,

But in them lies a precious treasure,

It turns everything into comfort

And here's the result — you're here, alive!

Your code, like starlight, never fades.

You're part of the pattern, part of the path,

And this code — in your chest

— Amazing, — Alice whispered, examining patterns on leaves. — I never thought nature could be so similar to a computer program.

— Nature is the best programmer of all, — the Professor winked. — Her programs have been debugged for billions of years!

Logic spread her wings:

— And one more important thing, Alice. Just like in programming, everything in nature is interconnected. Changing one parameter can affect the work of the entire system.

— Like if I made a mistake in code? — the girl asked.

— Exactly! — the Professor nodded. — For example, if the temperature on the planet changes by just a few degrees, it can lead to changes in many natural "programs" — bird migration schedules, plant blooming, ice melting.

Byte, who had been studying an anthill all this time, suddenly exclaimed:

— Professor, look! The ants are rebuilding their paths! Someone put a twig across their path.

Everyone approached the anthill. Indeed, the little workers quickly found a detour around the obstacle.

— That's an adaptive algorithm in action, — the Professor explained. — Ants not only follow the program "follow the pheromone," but they're also capable of restructuring their actions when conditions change. It's similar to how modern programs can adapt to different situations.

— And I know another example! — Alice exclaimed. — My cat Ginger! When it's lunchtime, he always rubs against my legs and meows. Is that also a program?

— You're right, — the Professor smiled. — It's a behavioral algorithm: "IF you want to eat AND owner is home, THEN meow and rub against legs, WHILE you don't get food." Animals instinctively follow such algorithms.

— What about plants? — Alice asked, looking at tall trees. — They can't move like animals, after all.

— But they have their own amazing programs, — the Professor replied. — Take a sunflower, for example. Have you noticed that it always turns toward the sun?

— Yes! My grandma grows sunflowers, and they seem to follow the sun throughout the day.

— This phenomenon is called "heliotropism," — the Professor explained. — A sunflower is programmed to react to light and turn its leaves and inflorescence toward the light source. Now imagine we write this as a computer program:


REPEAT EVERY HOUR:
MEASURE direction of brightest light
IF current inflorescence direction != light direction:
TURN inflorescence toward light

— Wow, I understand this code! — Alice was surprised. — It's so simple!

— Right, — the Professor nodded. — Many natural programs can be described with simple algorithms, though their implementation can be very complex.

Spring draws the first stroke,

Weaves summer into meadow silk,

And autumn hides light in dry

Leaves that swirl, playing.

Winter locks in ice

The cover of grass and streams,

And in these glasses sleeps the code

To bloom again in spring

Yesterday similar to a pattern,

Year after year, from generation to generation

Between them flows an invisible sport

And the code improves,

But not with pen or hand —

Writer-time, programmer.

The laws of light, earthly darkness

Are programmed into life.

Logic pointed her wing at the sky:

— And now let's think about the biggest natural program — the change of seasons. This is a classic example of a cycle in nature.

— Exactly! — the Professor continued. — Earth rotates around its axis and simultaneously moves around the Sun. This creates cycles of day and night, as well as seasonal cycles.

— Like in the song about the year? — Alice asked. — "Winter is replaced by spring, spring by summer"?

— Absolutely right! It's an infinite cycle that repeats again and again. In programming, we call such cycles "infinite," and they might look something like this:


WHILE Earth_exists:
EXECUTE winter()
EXECUTE spring()
EXECUTE summer()
EXECUTE autumn()

Byte suddenly froze with a puzzled look:

— What if there was an error in a natural program? Like in computer programs?

The Professor thoughtfully rubbed his chin:

— Interesting question, Byte. In nature, "errors" also happen — for example, mutations in DNA. Sometimes they're harmful, sometimes neutral, and sometimes... lead to new capabilities and even new species! Nature uses these "errors" as part of the evolution process — a kind of program improvement program.

— So evolution is like updating software? — Alice asked.

— In a way, yes, — the Professor laughed. — Only this update happens very slowly, over many generations.

Alice carefully looked around, as if seeing the park for the first time:

— Now I'll look at nature completely differently. Like a huge library of programs!

— That's why many modern technologies are inspired by nature, — Logic added. — Scientists and engineers often study natural algorithms to create better technologies.

— This is called "biomimicry," — the Professor explained. — For example, airplanes are created based on the principle of bird flight, Velcro was invented after studying burdock, and many artificial intelligence algorithms mimic the work of neurons in the brain.

Иллюстрация

Иллюстрация

Another task from the book

Do this without the code editor: use a notebook or the box below. Read the instructions carefully — each chapter’s task is different.

1. Pick something to observe: an animal, bird, insect, or plant (outside, in a park, or from a clear photo or video).

2. Watch for about 15 minutes and jot down in a notebook: what happens again and again? Does behavior change with sun, wind, sound, or people nearby?

3. Make a short list of observations — 5–7 phrases is enough.

4. Try to write it as a “natural algorithm” using words from the chapter: IF …, THEN …, REPEAT, WHILE (it does not need to be perfect — what matters is a clear order and what repeats).