Talk about the love triangle between programmers, compilers, and CPUs.

Source: Internet
Author: User


The evolutionary history of programming work

1, the CPU needs only 1 and 0 binary data composition

(1) No matter how the program changes, the final programming of the resulting executable binaries are for the CPU to run. The CPU needs only a bunch of binary 1 and 0 numbers (machine code) that are arranged in accordance with the rules of the CPU design (machine instructions), and the CPU simply does not care how these binaries come into being.

(2) These binaries may be a very powerful programmer directly with 1 and 0 to spell out, or it can be compiled in assembler language, or can be written in C language eventually compiled, or can be written in Java C # PHP bash and other languages and then explained;

(3) The evolution of programming has always been in the process of dealing with a hierarchy of paragraphs: the language in which the program was written (programmed in a language), and then how to turn the program source code into binary (the invention of the compiler).

(4) How the CPU receives a sequence of 1010 sequences to work to achieve the goal, this is the design and manufacture of CPU companies to consider things, and software engineers completely unrelated.


2. Early Paper punch Programmer

(1) At the earliest, the CPU was very simple, the instruction set was very small and the number of binary bits was not much. At that time the compiler was not invented, and the programming language was not invented, then it was programmed directly with binary.

(2) Summary: The earliest programming has no language and no compilers, and programmers use binary and machine (CPU) dialogs directly.

(3) The disadvantage of this way is not easy to expand, with the further complication of the CPU, more instructions, the number of instruction bits, the programming difficulty in geometric multiples increase. The human brain slowly can't keep up with the rhythm.


3, the first revolution of programming work: from binary machine code to assembly language

(1) The first revolution was: the invention of assembly language. The essence of assembly language is to replace a string of binaries with a symbol.

MOV 10101010101010

SUB01010101010101

(2) with assembly language, the programmer will no longer have to memorize the binary sequence. Programming can only be programmed with assembly instructions, assembly instructions is a symbol (the symbol is composed of text, such as MOV). Because the human brain is inherently more friendly to character symbols, it is easier to use symbolic programming.

(3) The source program written in assembly language can not directly run to the CPU, it must pass a translation process, the source code into a binary sequence to the CPU. The process of translation is called Assembly, and the translation is performed by the assembler.


4, the second revolution in programming: From assembly language to C

(1) Assembly language also has some unsatisfactory place, for example: no portability. The assembler written on this CPU cannot run directly on the other CPU. Therefore, the assembly language corresponds to CPU one by one.

(2) The invention of high-level language for portability. The first high-level language is the C language. C language further close to human thinking, human thinking invented a lot of things that the CPU does not, such as arrays. The ultimate goal is to reduce the difficulty of programming, so that the high-level language closer to people's thinking, and then through the compiler, assembler and other translation of these source code into a binary and then to the CPU run.


5, the revolution is endless, the level becomes more

(1) There are more advanced languages on the C language, for example: C + +, Java, C #, bash, etc. The more the closer to the person's thinking, the more the language itself provides more packaging, the more difficult to programming, the language of the more easy to grasp.


1, CPU only know binary machine instructions

(1) The CPU is ultimately working, and the CPU only knows to accept binary.

2. Humans like symbols rather than binary

(1) The human brain does not like binary and likes symbols and words.

(2) There is a generation gap between human and machine, so programming is not easy.


3. The bridge between the person (programmer) and the Machine (CPU): Compiler

(1) The compiler reduces the difficulty of programming. The compiler's representative is the programming language, each programming language has the corresponding compiler, the function of this compiler is to compile the source file of this language into executable program.

(2) The key is: with the compiler (high-level language), we programmers no longer stare at the CPU (binary), but instead stare at the compiler (programming language, programming language syntax), so we learn the key to programming is the habit of learning compiler, that is, the syntax of programming language.


4. The key to inventing a language is to invent its compiler.

(1) The key to compiling a language is the compiler. Yacc and Lex tools are used to invent programming languages.


5, the difference between the high-level language and the lower language

(1) The more advanced the language is closer to the human mind, the lower the lower the language the closer the need for the machine.

(2) The total amount of human and machine labor (total complexity) is conserved. A man can be a little more complicated than a machine. A simple machine requires a little more complexity. This rule describes: the simpler the programming language, the simpler it is to use, the more complex the compiler is, the more complex the programming language and the more cumbersome the programmer is, the simpler the compiler design and the more efficient the CPU execution.



Think like a compiler.

What is the grammar? Grammar is the habit of the compiler.

(1) compiler response is syntax in programming.

For example 1:

for (i=0; i<10; i++);

{

xxx

}


For example 2:

int i; !! I

Parsing: In C language is the logical inversion of meaning, the logical inverse means that 0 is 1, not 0 of the number of the reverse is 0

Problem: let you program in C: If a number i is 0 then return 0, if not 0 then return 1

General implementation:if (i = = 0) {return 0;} Else{return 1;}

Or you can use the three-female operator: (i==0)? (0):(1);

Geek style:!! I


Learning a language is like meeting a friend.

(1) New beginning to know a person to become good friends, here to experience: time, work together.

(2) Learning a programming language also requires: time, practice (working together)

Learning programming language to know how to think in a different place

(1) Preprocessing in the processing program comments, blank lines.


This article is from the "Mao Scattered People" blog, please be sure to keep this source http://songmao.blog.51cto.com/11700139/1880887

Talk about the love triangle between programmers, compilers, and CPUs.

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.