system
Given the following post, respond as if you're commenting on Reddit:
human
How did complex systems like our circulation system evolve?

I have a scientific background mainly in math and computer science and some parts of evolution make sense to me like birds evolving better suited beaks or viruses evolving to spread faster. These things evolve in small changes each of which has a benefit.

But a circulation system needs a number of different parts to work, you need a heart at least 1 lung, blood vessels and blood to carry the oxygen around. Each of these very complex and has multicellular structure (except blood).

I see how having a circulation system gives an organism an advantage but not how we got here.

The only explanation I have found on the Internet is that we can see genetic similarities between us and organisms without a circulation system but that feels very weak evidence.

To my computer science brain evolution feels like making a series of small tweaks to a computer program, changing a variable or adding a line of code. Adding a circulation system feels a lot more than a tweak and would be the equivalent of adding a new features that required multiple changes across many files and probably the introduction whole new components and those changes need to be done to work together to achieve the overall goal.

Many thx

EDIT Thanks for all the responses so far, I have only had time to skim through them so far. In particular thanks to those that have given possible evolutionary paths to evolve form a simple organism to a human with a complex circulation system.
gpt
Here's an intuitive description of one candidate pathway:

(1) Some very simple sea creatures started eating bacteria that floated into them.

(2) Some creatures (like sponges) evolved pores to filter more food from the water. This made them more effective at gathering food.

(3) These pores evolved into long digestive (somewhat vein-like) channels for the water to pass through. This gave them more area to use to digest the food.

(4) Some creatures began wiggling to pump more water through their digestive channels. This gave them the evolutionary advantage of getting more food.

(5) As digestion evolved, some of these digestive channels became internally separate. (So food first passed through the main digestive channel, then was further circulated in secondary channels.)

(6) Some of these secondary digestive channels started evolving "special" water to help transport the food. (This was the precursor to blood.)

(7) Eventually, the circulatory system began to be quite different and separate from the digestive system, although they were both still just a series of tubes.

(8) Instead of pumping the blood by wiggling, some creatures could save energy by just flexing the muscles immediately around their veins.

(9) Gradually, this evolved in to a heart.