A few years ago-no, it should have been a few years ago-if it hadn't been so long, I really couldn't tell it out-it wasn't always carefree-when I was a child, one day, dad suddenly said to me, "I saw that the game machine is very interesting. buy one for you ". Look, I was so happy that you may want to see it! -- I have always loved toys better than delicious things, but I did not expect to buy that things. It was still a rare thing. I had seen it on TV before.
You guessed it was right. Dad said that the game machine is a classic Nintendo red and white machine.
Saying that I stood in front of the counter selling game machines and watched the game cards, posters, handles, laser guns and big televisions filled with walls. The game card that the boss recommended to me was the most classic I of the time. In my hand, I held the yellow plastic shell of the game card, staring at the two strong men with machine guns printed on it, and began to fantasizing about how fun the game was. At this time, suddenly, I asked the most silly question in my life --
"Well, how long can this card be played normally ?"
Today, this silly boy has become a silly uncle (with God's care) and has been a programmer for seven years. However, he still cannot say that he really understands the computer-because he still feels "amazing" when playing games! ". Every time I enter the game, it is like a new story. Unlike transformers, it can only be changed from a car to a robot, or from a robot to a car. It is not like the Plasticine. Although theoretically it is ever-changing, it isUnstructured-- That is, if you input anything, It outputs nothing without the feeling of interaction. If you want to make a metaphor, I think the game is like a river. Although it has a fixed bed, every time there is a different refreshing river flowing between your legs, different fish are playing and jumping out of the water.
System Structure
If you have the opportunity to see the automated devices designed by humans or in nature, you can often find that their structures are largely controlled by the possible failures of these automated devices and the corresponding preventive testing methods (more or less effective) taken to deal with the failures ). It seems a little exaggerated that they can prevent faults. It seems that they adopt an optimistic description method different from this topic. They are designed not to prevent faults, but to prevent the system from failing when most of the faults occur. It is impossible to eliminate all the faults or eliminate the impact of the faults. What we can try to do is to design an automatic device, this allows the system to continue working in the event of most failures. This device reduces the damage caused by the fault, rather than eliminating the fault itself. Most of the artificial and natural automated devices and their internal principles do not.
-- John von noriman
When I was playing Transformers, I had a lot of complaints. I am always staring at robots that have repeatedly changed many times, and imagining that there must be some wonderful forms that have not been discovered by me.
If both transformer and Soldado are regarded as a system, which has an internal state that coexist in an external environment, and the external environment also has a state, these two States always determine the next internal state. If I was a child, I would like to ask myself, "Same as the system, how is the gap so big? ". Compared with the two States in the Transformers zone, the input and internal states that soul arms can receive are almost infinite. Indeed, many computer programs are incredibly magical because they can receive infinite (at least a large number) input states. However, this capability is not unique to computers, and many systems in life can also be achieved.
First, let's talk about a linear system, such as a cutting machine. Its designers may have preset the ability to cut cucumbers, cut potatoes, cut apples ...... However, if we stick our fingers or JJ in, it will be okay. Of course, no dumb can be inserted into a steel bar. This is not because "do not add hard things" is written in the instruction book (how hard is it to be regarded as "Hard Things "?), But we know the cutting machine.InsideThe blade must be broken when it hits the steel bar. This is a sad reality: the original intention of the system designer is always to make the user think of the systemBlack BoxBut to make good use of the system, users often need to know more about the systemInternal statusAndImplementation Principle. If you do not tell them how they work, they will alsoGuess. When the TV was just invented, people guessed that there was a villain in the square box. If people have never understood the truth, we can imagine how many TV sets should be smashed when playing a video.
In the computer world, it is similar to cutting machine methods like AddOne.
static int AddOne(int a){ return a + 1;}
Thanks to the efforts of hardware engineers and Programming Language designers, it is as simple and straightforward for programmers to implement such a function as pressing the buttons on the cutting machine.
A little more complex, such as Sign.
static int Sign(int i){ if(i < 0) return -1; else if(i > 0) return 1; else return 0;}
Sign () is more advanced than AddOne ().CategoryReprocess. In the real world, a system similar to Sign () is a public toilet. Of course, you must have noticed that public toilets are incapable of dividing people into men, women, and neutral people. To do so, I am afraid complex hardware and software equipment are required.
What's more complicated is that input like sorting algorithms is a set. It is complicated because the collection cannot be divided into individual elements for processing, but it must be considered as a whole. In other words, the input must be treated as a system. In this way, the Sorting Algorithm becomes "input is a system", which is a bit awkward. We should consider the input as a system and the sorting algorithm as a system from another perspective.Adjustment. That's how it feels: new int [] {3, 1, 2}. Sort ().
We have mentioned in the previous articles that we cannot directly process a set in order, but we forgot to ask "why ?". The answer is "hardware does not support ". Imagine that if there is such a sort memory, it will generate "buoyancy" to the storage unit like a pool, and the larger the value in the storage unit, the larger the buoyancy power, the storage unit can also float and sink freely according to the received buoyancy, like a submarine, when we put the data in this "Sort memory", we will naturally get a sorted set.
When it comes to hardware, it is really difficult to get a glimpse of what functions the hardware provides as the starting point of programming. Let's briefly review the division of hardware and software in computer systems. The computer hardware itself is unstructured. It is like a Lego assembled toy just bought, with only some fragments that are not connected together. These fragments-commands, registers and random memory with four arithmetic operations/comparison sizes, and control commands such as addressing, data transfer, and redirection-are the "direct processing" functions provided by hardware. When we write software, we assemble these fragments into a system with a certain structure. When the system receives the input, the internal state of the system changes.
This statement seems to imply that "the Code is a structure and the variable (the data in it) is a state", but please be cautious with this statement. For AddOne () and Sign () functions, we can think that the system structure is only those if else statements, and the system state is the return value. However, when the system status is represented by a set, it is not easy to clearly identify it. Considering the heap introduced in article 4th, the data itself also has a structure (the so-called data structure), but whether it is a one-dimensional array or a binary tree depends on its code, system behaviors (such as running time) depend not only on the structure provided by the code, but also on the data structure. Another interesting example is the quick sorting of random variables described in Article 3rd. Even for the same input, the time (that is, the behavior of the system) consumed by calling randomization and fast sorting is different. In this way, from the perspective of black box, we cannot determine whether the program we sort is the same or different. We can only sayCode and data jointly reflect the state of the system. Structure and behavior, as part of the State, are also reflected by code and data.In other words, although the program code is written by the programmer early in the morning, the structure after the program runs isDynamic. Because of this, we can expect that one day the program will be able to learn, reason, innovate, solve problems, and be self-conscious ......
Why does Feng nuoman say "It is impossible to eliminate all faults or eliminate the impact of faults? Can a system designer accept such a depressing conclusion? To eliminate all faults, the system designer must: 1) strictly limit the input of the system to a limited preset range; 2) Ensure that, apart from input, the internal status of the system is not affected by any other external status. In some aspects, people's efforts (such as type security and DEP) have made us a huge step towards these two conditions. However, if we put the system in an infinitely broad, infinitely far-reaching external environment, we will find that it is only the wishful thinking of system designers to fully satisfy these two conditions. First, it is often difficult to limit the input range. Such a thing as "being forced into the poison and turning it into" is always happening. Second, it is difficult to enumerate all factors that may lead to system faults in advance. If you put something too hard, the cutting machine's blade will be broken. If you put something soft but strong in toughness, the cutting will continue. If you put it too sticky, it will not work. If it is too acidic, it will not work ...... Third, you can only allow tested input, but this will greatly weaken the system function. No one will be willing to buy a cutting machine that can only cut cucumbers and potatoes (adding other things will cause the machine to blow itself up immediately); an algorithm that can only sort 10 elements is enough to make people speechless; fourth, although there are only two well-sold systems like Transformers, we still cannot prevent the internal screws of transformers from being corroded or rusted, its shell is deformed in an overheated or undercooled environment (deformation !!) Or break.
Not to mention Hack. The system is always applicable to the existing environment or is designed based on the existing environment. What will happen when we place the system in an unexpected external environment, or directly modify the internal state of the system? Eye shadows, lipsticks, bras, and stockings plus a pair of high heels are the simplest and most practical Hack equipment. Even better, you know that it is a kind of Hack, you will still be eager to watch (this shows that some parts of the system are easy to change, but others are extremely difficult to change ). As for the example of directly modifying the internal status of the system, I would like to give you an example of drinking a cup of coffee every day. "Just like running engines produce exhaust gas, neural activities emit a chemical called adenosine. The accumulation of ATP will make us feel tired, so our bodies will remind us that we should go to bed. The body uses a cell called receptor to detect the amount of ATP. As one day, more and more receptor is produced, more and more receptor is filled. No matter how intense the stimulus is, our brain cells become increasingly slow and tired. During sleep, the night shift would clean up the camp. We will feel better when we wake up, because our minds become clearer ." This is a mechanism that can work well. But when caffeine enters the human body, "because it happens to be similar in shape, caffeine enters the receptor that originally receives the ATP. Once you get in, caffeine will camp to stop working with it. So maybe we have been working like crazy for a few hours, and the brain is supposed to be full of ATP, and we should have been so tired, but the receptor is blocked by caffeine and cannot work, we can't pass the information we should go to bed, so we will feel surprisingly awake and still be prepared to do a big job." (From instinct)
Sometimes programming is like pickles.
What should we do when the system is in a disordered state and the hardware capability does not support adjusting the system to an ordered state at once? Through the previous articles, we can see that people not only have found feasible methods, but also there are more than one method. What do these methods have in common? If so, what are their principles? Maybe, we can get some inspiration from the story of purriscott. This somewhat depressing, thought-provoking, and interesting story is what I saw several years ago in winberger's book The mysteries of consulting:
The puriscott mass store is a model of integrity, and the same is true for puriscott itself. No-salted pickles can be as good as puriscott's.
"We have a secret recipe for family creden. My father gave it to me, and my grandfather gave it to him ." He said.
"I Don't Want To plagiarize your recipe. But I'm trying to learn how to save things. Can you give me some secrets about making pickles ?" Said Winnie.
"Okay, maybe I can tell you something ." "My grandfather once told a story about a stubborn cucumber. At that time, he put the cucumber into a bucket to prepare for pickling. The cucumber looked around and looked at the cucumber in the same situation as him, preparing to resist the situation. 'Really annoying! 'It cursed, 'what happened to you guys? Do you have no courage? No self-respecting cucumber will marinate itself without any resistance. '
"'But what can we do? 'The cucumber asked, 'you canBoycottThis is what you can do, and we don't want to do it. Salt water won't fall below us. '
"Then my grandfather will stop, and I will always ask him, 'what happened to the stubborn cucumber? '"
"What does he say ?" Wen Berger asked.
"He said, 'Don't be so stupid, kid.If you stay in salt water for a long time, you will also become pickles.. '"
This isPrinciple of purricot pickles(Prescott's Pickle Principle ):It is cucumber that becomes more like pickles, not brine that becomes more like cucumber.
Another way is to explain the principle of puriscott PICKLES:It is easier to change a small system of a large system after a long period of contact..
Whether it is insert sorting or Merge Sorting, we are creating this kind of trend: the vast majority of the system is ordered, and the unordered part is always a small part, so that the entire system is more likely to become orderly. In the fast sorting and heap sorting algorithms, we can easily find the shadows of the principle of pickles.
Let's talk a little more about the problem. The first time I heard the story of the, I felt sad and puzzled-why did the students who were both studious and brave enough to practice end up with such a miserable ending? It must be because he could not "eat" new knowledge of his existing knowledge. He learned too much and learned too fast, this knowledge fails to form a stable and hierarchical system in his mind. The more he learns, the faster he learns, and the more out-of-order the system. So, let's practice basic skills more every day and do more abstract thinking. Although they don't seem as useful as practical skills, they are so interesting and have a sense of accomplishment.