A program is a set of instructions that are executed in sequence.
The first answer is actually no answer for most people, because the concept of algorithm may be a more complicated concept than the program.
The second answer is a little easy to understand, but it doesn't make people understand what the program can and can't do.
First, the menu
Ingredients: half a catty of pork belly, one pepper, 4-5 green garlic, (in fact, authentic Sichuan-style pork is decorated with dried bean curd and a red pepper, which is not available at home, so it is omitted), 2 teaspoons of white sugar, 1 tablespoon of soy sauce, 2 grams of salt, chicken essence, cooking wine, ginger slices and onion segments; Garlic slices, Pixian bean paste 1 tablespoon
Practice: Pretreatment: put the whole pork belly in hot water and cook it (chopsticks can be pierced thoroughly). During the period, order some cooking wine, put two pieces of ginger and two or three pieces of onion; Then put it in cold water to cool. Among them, the step of cold water cooling can make the meat shrink quickly, help shape and increase chewing intensity, which is a key step for ordinary chefs to become chefs and cannot be omitted.
Cut the green pepper into diamond-shaped sections, pat the garlic with green garlic and cut it into inches. Garlic and garlic leaves are separated.
Slice the pretreated pork belly as thin as possible. This is all I have. Relatively thick.
Garlic mashed (not pat), Pixian watercress chopped into velvet (broken and delicious).
Put the processed meat slices into the oil pan and stir fry over high fire. Until the meat slices roll up and turn brown.
Put aside the super-good meat slices, add minced garlic and Pixian watercress, and stir-fry the red oil with low heat.
Add pepper and garlic, add sugar, soy sauce and salt. Note: Pixian bean paste and soy sauce are salty, so be sure to put salt properly.
When the pepper and garlic are fragrant, add the green garlic leaves and chicken essence and soak them evenly. The green garlic leaves ripen quickly, which takes only 30 seconds or even less, as long as you see the green garlic leaves wrapped in oil.
pan
The above is the Sichuan pork recipe found online (it seems that this is good wine). Broadly speaking, this is also a procedure. How can I put it?
This program is slightly different from the computer program. The operator of this program is a person who can understand the above words, correctly understand the meaning of each sentence, and have the ability to obtain the material and execute it step by step. And a compute program is a statement that a computer can understand and execute.
Second, why should there be a programming language?
Just like the recipe above, as long as we know Chinese characters, we can basically follow them. Why is there a programming language that people can't seem to accept at once?
Natural language is vague.
The male teacher found a girl sleeping in class and said angrily, I'm so tired up there, but you don't move down there! If you don't cooperate, you won't even respond If you have nothing in your stomach in the future, don't blame the teacher!
No one can win the football team in China. No one on the China table tennis team can win.
It's too cold in winter, so try to put on more clothes when you go out. It's too hot in summer, so try to put on more clothes when you go out.
I heard a girl talking to her boyfriend on the subway. "I have arrived in Xizhimen, please come out and walk to the subway station." If you arrive and I haven't, just wait. If I arrive and you haven't, just wait. "
The wife called the husband who was a programmer: buy a catty of steamed buns and bring them back from work. If you see a watermelon seller, buy one. That night, the programmer's husband came into the house with a steamed bun in his hand ... The wife said angrily, why did you buy steamed buns? ! Husband replied: because I saw the watermelon seller.
The above is the most typical ambiguity in Chinese, and there are many such ambiguities in other languages. Look at the last sentence of the programmer, then it means that the wife gave a series of instructions but the executor carried them out in another sense. Of course, this example is still inappropriate. We can also change the instructions to: "Buy a catty of steamed stuffed bun and bring it back from work, and buy a watermelon when you see a watermelon seller." . But the trouble is that Chinese itself does not restrict us from doing so, and the usage in other examples is even more difficult to determine the meaning, and it also involves context. So today, computers are still very bad at dealing with natural languages.
Natural language instability
666, shrimp, sauce purple, sofa, vermicelli
These words have added a layer of meaning after the internet, and people who don't surf the internet may not know it at all. Of course, instability still brings essential ambiguity.
For these reasons, there are mathematical languages (in fact, there are ambiguities, otherwise there will be no branches of mathematical logic) and programming languages to avoid ambiguity.
Third, what is the procedure?
This is really a difficult word to define, and the more reliable answer involves mathematical logic. Neither recursive function theory, Turing machine model nor lambda calculus is so easy to master. These are far more difficult than learning a programming language and mastering programming. So here is an image metaphor. A program is an instruction that a compiler or interpreter can understand (this thing may listen to you more than anyone else, as long as you can command it in a language it understands).
When we open WeChat, we can go directly to WeChat. We can send messages to friends, add friends and send friends. It will do whatever we give. We give orders by clicking on the screen. Compilers and interpreters are similar things, but this thing only accepts the instructions it knows, and all the instructions it accepts are words (mainly English, numbers and punctuation).
Fourthly, calculation, isomorphism and simulation.
For example, for the same thing, if we want to calculate 3+5, then we can have:
Three fingers on the left hand and five fingers on the right hand add up to eight fingers.
Take out three balls first, then five balls, and put them together to make eight balls.
We enter 3+5 in the calculator to get 8.
All three methods can calculate the value of 3+5. They use different methods, but they are equivalent in calculating the core of 3+5. That is the concept of isomorphism.
With isomorphism, we can simulate. For example, if you have a small ball, use it for addition. But I don't have a ball. I can use my finger or stone instead of the ball to simulate you adding with the ball and get the same result as you.
How do we use programs to do things? Mainly use the data in the computer to simulate real things.
For example, if your head moves to the left in the camera, it is essentially to subtract a certain value from the X coordinate of the data representing your head in the computer and finally output it to the display.
For example, if you solve an equation on paper, there is also a process in the computer to simulate every step of your calculation and get the same value as you. It's just that you do it with paper and pen, and the computer does it in its way.