How the program translated into other forms?
At first ,we should understand about th
How the program translated into other forms?
At first ,we should understand about the complitation systems.
When we first meet the programming language,wo are curious about how can it really be convert into the word"hello world",we use the language that we can understand,but the machine will not read it.we should owe it to the hard word of some scientists who developed the compiler that down the gate of programming.
1.2 The Compilation Systems
1. preprocessing phrase: tools:preprocessor
we use the directives(命令) that begins with the # character,such as"#include<stdio.h" (#include<iostream>in c++ instead),and the directives should be used.the preprocessor will insert the directives from the PC into the program text,causing the .i file.
2.Complitation phrase: tools:complier
the complier translates the .i file into the .s file,which contains the assembly language.We should know that no matter how high-level langhage you are(c,c++,php,python,etc..),at last it will be generated in to the same assembly language.
3.assembly phrase: tools:assembler
the assembly language is translated into machine langhage,package them at the recollatable object program(可重载项目),contained in hello.o.And it will be a binary file(二进制文件),that we can't read it by the text editor.
4.linking phrase: tools:linker
the linking will happen between function.o(like printf.o)and object program(like hello.o).the result is a executable object file(like hello)which will be loaded in the memory.
Tips:The GNU project really is a great miracle,it helps the wide_range of UNIX and free-opensource action.The computer environment today we can enjoy is built from this.
1.3 Why we shoulud understand about the Complitation Systems
This is a valuable question,yes,yet we have the sophisticated complitation systems and it will help us communicate with the hardware,why we still need to learn the compiler:
1.Optimizing program performance: 优化系统性能
Not only we should konw how will work,we should know more about why it works in such way.
To redece many avoidable bugs,we should know: the pointer,the array index,the efficiency of 3 loop ways,and so on.
an then we will understand the nature of the machine.