C ++ from scratch (1) -- What is programming

Source: Internet
Author: User

Introduction

Some people have asked me some basic questions, however, these people have been able to use VC to compile a dialog box interface for necessary operations or the document/visual interface to receive port data in real time and dynamically display the curve (multithreading technology is also used ), even those basic problems are unclear, and the most serious consequence is to write poor code (although multithreading, It is not flattering). It is not clear the meaning of the class, mixed use of various available technologies to achieve the goal (exceptions are used instead of selection statements), the code logic is chaotic, and the translation effect is the same as that of Kingsoft fast translation.
I think that everything is the most important foundation, and I will not do programming after I finish the last custom project. It makes no sense to keep up with these experiences, here I will use this series to talk about my understanding of programming and help people who are interested in computer programming get started quickly (but it may not be as fast as I think ). Because I have never read a C ++ book (all of which are fragmented and occasionally flipped through), and this series does not list the damn Terms and explanations in a systematic manner, instead of learning a language (that is, not only English but also English ). The entire series is fully written in my own understanding, and there is no reference to other teaching materials (for some basic concepts, refer to MSDN ), therefore, the content in this series may be different from that in the classic textbooks, but they should be the same in nature, but they only have different perspectives. This series will not explain every keyword of C ++ carefully (some are not important). After all, it is not a reference of C ++ language, but a programming entry. If you have not mentioned any content in this series of articles, please refer to the C ++ language reference in MSDN (you should be able to do this after reading this series of articles ), the content provided in this series is based on the VC compiler and based on the 32-bit Windows operating system.
The title and main content of each article are listed below. The title of a red post indicates the key point I think.
C ++ starts from scratch (1) -- What is programming (indicating the true meaning of programming and two basic concepts that are easy to ignore)
C ++ starts from scratch (2) -- what is an expression (indicating the usefulness of each operator, but not all. The rest will be mentioned in other articles)
C ++ starts from scratch (3) -- what is a variable (describes how computers work and describes important concepts such as memory and address)
C ++ starts from scratch (4) -- Value assignment operator (continuation of "C ++ starts from scratch (2)" and lays a foundation for pointer interpretation)
C ++ starts from scratch (5) -- what is a pointer (describes important concepts such as pointers and arrays)
C ++ from scratch (6) -- what is a statement (explain the various statements provided by C ++ and explain their reasons)
C ++ starts from scratch (7) -- what is a function (indicating the function and its reasons)
C ++ from scratch (8) -- C ++ Example 1 (one or two simple algorithms are provided to illustrate how to compile C ++ code from algorithms step by step)
C ++ starts from scratch (9) -- what is the structure (briefly describe the structure, enumeration, and other reasons for its existence)
C ++ starts from scratch (10) -- what is a class (describe the reason for the class and its existence, as well as concepts such as declaration, definition, and header file)
C ++ starts from scratch (11)-class-related knowledge (meaning derivation, inheritance, namespace, Operator overloading, etc)
C ++ from scratch (12) -- What is object-oriented programming ideology (elaborate what is programming ideology and focus on object-oriented programming ideology)
C ++ from scratch (13th) -- C ++ Example 2 (describes how to design C ++ programs based on object-oriented programming ideas)
C ++ from scratch (14th) -- what is a template (describe the template technology and its reasons)
C ++ starts from scratch (15th) -- what is an exception (describe abnormal technology and its reasons)
C ++ starts from scratch (16th) -- What is pre-compiled instruction (describe the concept of pre-compiled instruction and application of several common instructions)
C ++ from scratch (17th) -- Some uncommon keywords in C ++ (descriptions of explicit, mutable, and volatile)
C ++ starts from scratch (18th) -- What is SDK (indicating why music programs can still be compiled without instructions)
C ++ starts from scratch (19th) -- what is the C Runtime Library (the culprit of most problems in C Runtime Library)
C ++ from scratch (20) -- a little bit of basic knowledge about VC (describes several basic concepts and some common settings of VC)
C ++ from scratch (21) -- C ++ Example 3 (use VC to compile a simple program that implements polymorphism through DLL)


What is a program?

Programs, that is, the sequence of processes. To be precise, they should be multiple processes in an ordered order, and they are descriptions of methods. For example, you can take a dish with chopsticks, feed it into your mouth with chopsticks, chew it, and swallow it. The folder, send, chew, and swallow are called commands, while the dish is a resource, and its status (such as shape and position) changes with the execution of commands. The above is the description of the method for food, that is, the Program for food.
Any method exists to change the status of some resources. Therefore, the description of any method, that is, the program, must have the command and the resources it serves. Commands are implemented by the executors of the program. For example, the food on top, the food folder and delivery are all implemented by the person who eats the food, the resource must be something that the executor can change, and the command only tells the executor how to change it.
Computer programs, like the above, are methods described, and these methods are what people expect the computer to do (note that they are not what the computer is doing, which is often confused by many people ), when people need to do these things, they will give some resources so that computers can make the right changes to them. For example, the Program for calculating the circumference rate is only a description of the method, and itself cannot have any utility until it is executed and a piece of memory is manually specified (about the memory, refer to "C ++ from scratch (3)") and tell it the accuracy of the calculation result and the storage location of the calculation result, it only changes the state of a given piece of memory to show the computing result.
Therefore, for computer programs, commands are CPU commands, and executors must be CPU commands, the final resource is the memory in which the CPU can change its status (of course not only, such as the port, but generally the applications use a lot of memory ). Therefore, a computer program is the description of how the computer changes the given resources (generally memory, or other hardware resources). Note that the description is meaningless unless it is executed.


What is programming

Programming is writing programs, that is, developing methods. Why is there a way? The method is to illustrate. There are many reasons to explain this, but the root cause of computer programming is that different languages are different, and the concept of connection is different.
Human languages are varied, but we can get positive solutions through translation, because humans live in the same four-dimensional physical space and have the same or similar perception. However, the space that the CPU can feel when executing a computer program is significantly different from that of a physical space. Therefore, it is impossible to translate computer programs into human language descriptions. This is very important. It leads to poor Code Compiled by most programmers. People and computers do not share the same idea, so they write programs randomly and unpurposefully, this leads to poor but executable code.
The language of a computer is the instruction of a CPU, because the CPU is aware of this path (precisely speaking, there are memory locations, interrupt responses, and other sensing channels). Unlike humans, there is still a physical language, therefore, computer programming is to translate the human language writing method into the corresponding computer language, which is a translation process. This is completely different from general translation. Because of the red letter above, it is impossible to translate.
Since it is impossible to translate, what is computer programming? Consider a carpenter. I am a guest. I told the carpenter that I needed a rocking chair, which was quite comfortable to lie down. Then the carpenter began to dig the wood and follow a special curve to make the curve below the rocking chair to ensure that the center of gravity remains unchanged and it feels quite comfortable. Here I have compiled a simple program with only one command-a comfortable rocking chair. The carpenter translates my program into a series of programs that I don't understand, such as planing wood and designing specific crumu. The reason for this is that the space in my life is not the same as that in woodworking (woodworking, not carpenter. Here the carpenter is equivalent to a computer programmer and a CPU (because the carpenter finally creates a rocking chair), and the carpenter's craft is the instruction definition of the CPU, the carpenter translates my program into some woodworking procedures, which are implemented by the carpenter through his craft, that is, the execution procedures.
Since the space I live in has no commonalities with woodworking Technology (it refers to woodworking technology, not a worker), it is impossible to translate it. However, the translation was successful, but there was no translation. In the woodworking eyes, the rocking chair is just a splicing of direct wood and qumu. Because there is no concept of rocking chair in the woodworking space, I just want to use the pile of wood as a rocking chair. If I use the heap of wood as the weapon, it is not a rocking chair.
"Nonsense and absurd !", Maybe you will yell, but computer programming is like this. The CPU can only perceive commands and change the memory status (regardless of other hardware resources and responses). If we write a program to calculate the circumference rate, provide a piece of memory and execute it, the computer screen displays the correct result. However, it must be noted that the computer only copies, adds, adds, and removes some memory values. The computer does not know the circumference rate, if the person executing the program does not regard it as the circumference rate, the result will not be the circumference rate. It may be a random number or something, but luck is very good and the circumference rate is surprisingly similar.
The above is called semantics, that is, the meaning of language. It can not only be applied to computer programming, but actually many technologies, such as machinery, electronics, and mathematics, all have their own languages, those designers are responsible for translating customers' simple programs into corresponding language descriptions. As a programmer, it is extremely necessary to understand the importance of semantics (I have elaborated on the code-level semantics in my other article "semantic needs, if you are interested, you can refer to it). In subsequent articles, I will also mention semantics and its impact on programming. If you have not understood what programming means, as the reading of subsequent articles becomes clearer and clearer.


Basic knowledge of computer programming-compiler and connector

I have never seen (but should have) Any C ++ textbook that has talked about Compiler and Linker (but I have seen it in very old C textbooks ), nowadays, many things are hidden and encapsulated in a programming environment like VC. Here, their understanding is very important. These two words will be widely used later in this series, it determines whether it can be understood, such as declaration, definition, external variables, header files, and so on.
As mentioned above, computer programming is a "Translation" process. To translate a user's program into CPU commands, it is actually machine code. The so-called machine code is a program written with CPU instructions, called a low-level language. The programmer's job is to compile machine code. Because the machine code is completely composed of numbers (CPU-aware everything is a number, even a command, only 1 represents addition, 2 represents the ing of subtraction and work ), people should remember that 1 represents addition, 2 represents subtraction will be more difficult, and remember that 3rd of the memory is placed in the circle rate, and 4th of the memory is put in the effective number of digits. Therefore, the assembly language is invented. Some symbols are used to represent addition instead of 1, such as adding.
Since the Assembly language is used, it is easier for people to remember it, but computers cannot understand it (they only know that 1 is addition, and they do not know that ADD is addition, because computers can only see numbers ), therefore, there must be something to translate assembly code into machine code, that is, the so-called compiler. That is, the compiler

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.