Chapter 1 enlightenment 1st what is a programming language

Source: Internet
Author: User

Chapter 4 enlightenment

1. 5. What is a programming language?

A program is a combination of commands according to certain logic. In the game, both parties use "Natural Language" to express "commands ". If both sides of the game are deaf-mute, you can't play with the set of commands you say with your mouth-computer is not easy to say, but when we want to give commands to the computer, the set of natural languages that are unique and have a long history of mankind is definitely not a good choice. What should I do?

The first thing we need to do to solve this problem is to develop the "machine language"-if the machine has a language, we can ......

Wait, machines, things without life! It seems a little disrespectful of human dignity that a kitten or puppy has a language to accept, a machine has a language to learn. Otherwise, some self-respecting students may have psychological barriers and cannot continue learning programming.

First of all, the language must not only represent the sound content, but also English and Chinese. It is spoken language and written on paper as a text language. A mute is a symbol expressed by some gestures.

As we mentioned above, "commands" are actually a set of communication symbols used to express those commands. As long as both parties can correctly understand this symbol. The human language is used to express the "commands" of computers. Of course, there are more than enough commands, but the key is that machines cannot understand them. So let's look for the most easy-to-understand symbol of a computer, use it as the language of a computer, and then learn about it.

It is one thing to let people learn the language that is suitable for machines. It is a headache for humans to remember the key machine language. We will talk about it later. Fortunately, the thing is not over: actually, as long as there are several computer scientists who have mastered the machine language, they can communicate with the machine, then we can gradually "teach" computers to "understand" some new languages that are closer to humans. In this way, common users can directly learn new programming languages.

1.5.1. Machine language

What language can computers understand at a glance?

Today, the computers we use are called "electronic computers" because they are still an important component of electronic components. With the electronic knowledge of my super poor hacker, I can still tell that the common electronic components include "resistance" and "capacitance". The resistance is related to it, what I learned in Middle School: "When the voltage is fixed, the current of the conductor is inversely proportional to its resistance"

-- It's big! Do we have to learn the knowledge of Complex electronic circuits to learn programming? Fortunately, all of this is worrying.

The ancients in China once invented an abacus. The abacus is divided into two upper and lower zones, where a bead in the upper zone represents 5, while a bead in the lower zone represents 1. The pioneers who invented electronic computers (including Comrade Feng noriman, of course) are equally smart. What they found is the basic symbols for electronic computers: power-on and power-off ".

However, if we have doubts, we can use the "communication" and "disconnections" States to express them. Is it a waste of the ability to express electronic components? Why is it not expressed by resistance or voltage? For example, 1 V indicates the number 1, 2 V indicates the number 2, 3 V indicates the number 3 ......

Only the "power-on" and "power-off" statuses are used as the basic symbols of computer languages, mainly for the demand of "accurate expression. Since the name is "computer", if this guy does not calculate accurately, what is the use of it? If the value of voltage, resistance, or current is used as the symbol of language, the first problem is that it is difficult to implement precision. Think about your light bulb and give it 220 volts to shine, 221 or 219 volts are almost bright, not to mention the amount of instruments, the pointer is also shaking, because in real life, it is difficult for us to precisely control the voltage value.

1.5.2. Machine language "letters"

Scientists use "0" and "1" to express "power-on" or "power-off ". However, they are only the "Basic symbols" of computer languages ". There are 26 letters in English, and the word is composed of 26 letters, followed by a group of idioms. We can also have machine languages with only two letters, namely power-on and power-off. To make it easier to express, we will say "0" and "1" in the future (0 indicates power-on or power-off, so we don't care about it ).

Easy moments: write a love letter in machine language

Haha, I didn't expect it. Who scared the guys to say that machine language is hard to learn? I think it is at least 13 times easier than English. Let's learn how to use it now. Do you have a male/girlfriend? First, let's talk about some methods of expressing "machine commands", such:

0: You

1: Me

10: Old

11: Places

100: Meet

101: Miss

111: Very, Very, that is quite

1000: Today

1001: Evening

1011: seven o'clock

1111: Dear

In the future, you can use custom computer machine languages to communicate with each other. For example, this is a letter:

"1111: 1 111 101 0! 1000 1001 1011 10 11 100 ."

1.5.3. Binary (basic)

Humans have 10 fingers, so humans use decimal. The electronic components have two most stable states: power-on and power-off. Therefore, the electronic computer uses binary.

In decimal format, we use 0 ~ 9 These 10 numbers are used to express all numbers. If they are converted to binary, they can only express all numbers with "0" and "1, in elementary school, the teacher taught us "every ten to one", so we know 9 + 1 = 10; then, in the binary world, 1 + 1 = 10. In binary, "10" (read as zero) is 2 in decimal.

In this way, we can use 0 and 1 to express all numbers. But in fact, all data in the computer is expressed by 0 and 1. However, according to the strict context, they do not necessarily represent numbers. On the contrary, they may be an MP3, a photo, or an email. For example, the value "250610" can be interpreted as "250,610" based on different contexts, or as a zip code in a certain area of Shandong Province, you can even think of it as a simple example.

Then, if you use a machine language with only 0 and 1 letters, then of course the 0 and 1 letters are written on paper. The earliest program is indeed written on paper, it's just more interesting than we think. Paper is a long tape, and 0 or 1 is represented by a circle. One circle, two circles, three circles. Where there is a circle, it is estimated that it is 1? Then hand it to the punching assistant, and place a hole in a circle. When the program needs to be executed, the paper is carried to the machine. It is really not complicated for a machine to understand these holes. For example, the light can be used for testing and the light can pass through the past. It should be 1.

1.5.4. Assembly Language

Do you still remember the love letter we wrote in binary format?

"1111: 1 111 101 01 1000 1001 1011 10 11 100 ."

I conservatively believe that using such a language to write love letters will not help you much, but it will certainly help you to keep the content of the letter confidential and also help you to exercise your memory.

Pure machine language is too difficult to remember and recognize. As a result, the philosophers immediately thought of creating a notebook for them. Because computers are invented by Westerners (not the only reason), they are short English letters and combinations. These Enis and their corresponding syntax rules are called assembly languages ".

For example, we want to implement this function: B is known to be equal to 1; C is equal to 2; B + C is calculated, and this value is assigned to. The binary machine language may be used as follows.

10001010 01010101 11000100

00000011 01010101 11000000

10001001 01010101 11001000

If you use an assembly language to write data, it may be as follows:

MoV edX, [ebp-0x3c]

Add edX, [ebp-0x40]

MoV [ebp-0x38], EDX

Assembly Language is a little more user-friendly than machine language, but it is still hard to remember. There is no essential difference between the two. It is only a simple translation. Many times, we regard assembly language as machine language.

Easy moments: assembly language is the leader in the "Rivers and Lakes"

Assembly language is the "leader" in the programming world ". He laid down the ground in the past, but today, he has rarely shown his face on the rivers and lakes. However, at some of the most difficult and critical moments, the compilation language is still required, and other languages fail.

The style of "boss" is "airtight ". Sometimes, even a very small task, "boss" can attack hundreds of lines of code. Some people will think that this style of work is too cumbersome. However, those who really understand the "boss" will find that hundreds of rows of tricks, fierce recruitment, and direct attacks to the key points. Let's take a closer look, nothing is superfluous.

In fact, to understand the assembly language, the most important thing is to understand the environment in which you are located, that is, the machine itself, until you really understand: "assembly is machine, machine is assembly ", the boss and JIANGHU have long been integrated. As long as you understand and do this, you can also be the "Boss ".

 

1.5.5. Advanced Language

Although the Assembly Language and machine language are hard to read, write, and remember, they do not need additional compilation, code efficiency is high, and memory usage is small, which is quite in line with the expensive memory of computers at that time, limited processor functions and other hardware features. From this point on, machine language is a language that makes humans suffer and makes machines comfortable.

As we have said, the philosophers have moved to computers and invented the "machine language". Then they should "teach" new languages that are closer to human thinking.

This is exactly the case. Shortly after the machine language was available, the philosophers began to consider how to implement programming languages that make humans comfortable to use. These languages, of course, try to conform to good human thinking habits in grammar organizations, but in turn they certainly cannot be called "machine languages" because machines cannot directly understand these languages. There are several solutions. The most typical method is "compile": You need to write a program called "compiler Program" in the machine language. The Compiler reads the code written in the new language, convert it into a machine language. Later, this compiler program can also be written in "advanced language.

These languages are called "Advanced languages" to distinguish them from "machine languages ". Where is "advanced" in advanced languages? I think it may be that they always try to be close to the "advanced animal"-people-way of thinking, right?

At this stage, the mainstream "process-oriented" and "object-oriented" ways of thinking are described here.

  • Process-oriented

    The most common solution to problems in daily life: to accomplish one thing, we should first break it down into several small tasks, that is, a relatively large "process ", split multiple small "processes" with time series relationships ".

    For example. Now, if a housewife wants to cook a dish, it may be divided into: cooking, cooking, serving ...... And so on. Among them, the "food preparation" process can be subdivided into food buying and cutting. (Frankly speaking, I am not familiar with the business process)

    Corresponding to the programming language, function/function is usually used to represent the process (some languages are called "process/procedure ").

  • Object-oriented

    The process-oriented approach is intuitive, but when the complexity of the problem is too high, we won't be able to figure out how many sub-processes we need very well. For example, let you serve as the director of the opening ceremony of the Olympic Games, in this case, we should not try to keep things from small to small.

    Object-oriented is in the face of complex problems, we first focus on what will be involved in the problem, and then regard different types of things as the basic unit, and define their respective data and behavior capabilities, and the relationship between different things.

    The "process" still exists and remains important in the "object-oriented" solution. Similar to a director filming a movie, the plot is the main process of a movie. However, the film shooting process does not follow the development of the story, and the complex reality will determine the order of shooting. For example, sometimes all the plots related to the Scenic Spot are taken in a scenic spot. At this time, the "scenic spot" is an important object and we must arrange things for development.

----------------------------------------

  • C Language

C is the leader in "process-oriented" language. One of the most important reasons is its positioning: In the two poles of "human" and "machine, it took a very elegant small step toward the "person" end. This is a small step in the C language itself, but a huge step in language development in programming history.

At the end of "human" thinking, it uses process-oriented thinking and provides clear and simple syntax rules. This syntax affects several important latencies, including object C, C ++, Java, C #, and D.

The C language is even known as the "intermediate" language when it approaches the "machine" feature-for example, when we need to write drivers for hardware devices. The reason is that it reflects the characteristics of machines, especially the memory. Therefore, it ensures good compatibility with the assembly language and replaces the assembly language, become the first language for operating systems, compiling programs, and running environments. C ++ developed directly from the C language. At first, the C ++ language was "compiled" into the C language and then compiled into the machine language. The Java language runs completely in the "virtual machine" built by C/C ++.

Easy moment: the boss's woman-C Language

C language, a mature woman, a standing woman, a light makeup woman, a woman with a deep heart, a woman with a needle in the needle when dealing with problems, the most hateful side.

C is more approachable than C ++/Java/C # in the younger generation. C is concise and clear ...... However, C is a sharp knife! Never think that she can be close to her because of her simplicity and kindness. A deep programmer uses C to solve the problem, while a simple programmer uses C to crash.

C language deeply understands the intention of compiling the boss, so it is often a few words that can replace the many command combinations of the boss. Unlike C ++, it never tries to let the compiler help find potential errors in the code. It gives all possibilities and all responsibilities to those who fall in love with her.

As the boss, the C language can not only be directly embedded into the assembly language, but also has a strong "affinity". If you have to find a language that can make orders, let other advanced languages support it, not C. In other words, if a high-level language cannot call the C language interface, it can only be a "Toy language ".

Linux, windows, Mac, and other operating systems are all written in C in combination with assembly languages. The reason is that you can collect your own traffic.

Jianghu rules: "the boss's Women" cannot be met-in fact, as long as you work hard to become a boss, you can proudly say "I only like her", just like Linus.

-------------------------------------

  • C ++ Language

The development of programming languages has evolved from low-level to advanced. We have already said that "low level" refers to "machine", while "advanced" refers to "human. So, in the middle of the development process, the most primitive driving force comes from the problems to be solved by the language, the fields in which it is located, it is also evolving from "machine problems" to "Problems in human society ".

A hardware-only machine is called bare metal ". At this time, ordinary people can hardly use it, so they need to write an operating system for it. In the two most widely used operating systems, the first name is "dos", and now the name is "Windows ". From the name, "Disk Operating System/disk operator system" is obviously biased towards machines, while "'windows' Operating System ", this operation not only provides a "window" graphical user interface, but also allows users to see a new blue sky and white clouds like opening a window ......

From the name, especially on the human operation interface, Windows is much more advanced than DOS in the "human" direction. However, the evolution of operating systems is only the beginning, and more importantly, the evolution of application software. A financial person who wants to use software to manage accounts; a specialist who wants to use software to manage files; a director who wants to use software management pipelines; and a teacher who wants to use software to manage student scores; A civil servant hopes to use software to improve the quality of service for the people ...... At this time, the focus of the software is not the disk, memory, CPU and other hardware, nor the data directly related to partitions, files, directories and other hardware, but various applications in human social activities. In this case, the C language that focuses on "Process Management" and is good at dealing with hardware seems a little powerless, so many new programming languages with a higher starting point have emerged. C ++ is one of the earliest such languages, and it is also the most widely used "Object-Oriented" language.

From the perspective of name, C ++ is developed on the basis of C language. In terms of implementation, C ++ and C ++ are the best supported languages for C language. They inherit many advantages of C language, the compiler's error correction capability is enhanced to support the syntax of programming ideas such as "Object-Oriented" and "generic.

C ++ is widely used to compile large-scale applications, such as Microsoft Office and Adobe Photoshop. The former is the most widely used office software in the world, it is also the most profitable software of Microsoft. The latter is the most widely used image processing software in the world. Even if you don't want to be an artist, you should have heard the word "PS master. In addition, due to the continuity of C language, C ++ has replaced some functions of C language in many occasions in the direction of "machine" development, for example, the COM component of the Windows operating system and some gui systems of the Linux operating system are mostly completed using C ++.

The main reason why we chose C ++ as the first language for learning is that we need to use it to learn the "Object-Oriented" programming ideology. However, C ++ is a language that can be integrated into everyone, it not only supports "Object-Oriented", but also supports "Object-based", "process-oriented", and the most comprehensive "generic" programming philosophy. Compared with Java, or C #, C ++ is not a pure "object-oriented" programming language, but this is exactly what C ++ pursues: "Different problems should be solved in different ways ".

-------------------------------------

If you want to communicate with me, click the following link to become a friend:
Http://student.csdn.net/invite.php? U= 112600 & C = f635b3cf130f350c

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.