In these four languages there are two different programs that run the process:
1. High-level language-machine code:
The compilation process for C and C + + has several steps:
> precompilation: Convert. c files to. i files, using the GCC command is: gcc–e, corresponding to pre-processing command CPP
> Compilation: Convert. c/.h files to. S files, using the GCC command: gcc–s, corresponding to the compile command cc–s
> Compilation: Convert. s files to. o files, using the GCC command is: gcc–c, corresponds to assembly command is as
> Links: Convert. o files to executable, gcc command used: gcc, corresponding to link command is LD
The first three steps can be called compilation, its output is a machine instruction, in the link will be the machine instruction and the target file library files together to generate the system executable file. exe.
2. High-level language--byte code--Machine code:
2.1 java
Java uses Javac to compile the source files into. Class bytecode and then continue to interpret and compile the executable machine code on the JVM. You may notice that there is a process of compiling and interpreting in the JVM process, which is related to the JVM's operating mechanism:
Before understanding this picture, understand the history of the JIT. At first, Sun used the classic VM as the JVM, but was plagued by "slower Java than C + +". Sun later introduced the hotspot as a virtual machine and introduced the JIT (Just in time) technology. JIT is also known as the instant compiler, although the compiler, it and the Javac compiler function is different. The JVM has three modes of operation: Interpretation mode, compilation mode, mixed mode. corresponding to the blending mode, the process is:
1. The source code passes through the compiler to become a. class file, which is a byte code.
2. The program bytecode is JIT-judged, whether it belongs to hot code, such as loops or frequently called methods.
3. If yes, JIT compiled into machine bytecode, corresponding to the specific hardware processor (such as Sparc,intel).
4. If not, be interpreted by the JIT interpreter for execution.
5. Calls to the operating system and the class library.
6. Hardware.
So the JIT is a collection of interpreters and compilers, some "hot code" can be compiled to save time-to-point explanation, the other code is still executed through the interpreter. Such mixed mode execution is faster than the pure compilation mode. So why is the pure compilation mode slower than mixed mode? The answers given in the blog are:
Compilation does not filter all the code to compile the machine code regardless of its execution frequency is compiled value, in the program response time constraints, the compiler can not take the compile time-consuming optimization technology (because JIT compilation is the first time to run or start the times!) ), therefore, the execution efficiency of Java programs in the pure compiled execution mode has a large gap with C + +.
It seems that Java is not a fully explanatory language.
2.2 Python
The python compilation process is run automatically and does not require additional manual action.
The py file is compiled into a. PYc bytecode file. This bytecode file is not platform dependent. The following is the implementation of this bytecode file by PVM, each of which is responsible for translating a bytecode file statement into a machine code that the CPU can execute directly, and then the next sentence.
For Python, there is no compilation of machine code, and each statement is executed directly to the source code or to the intermediate code. The process of compiling is less, which makes the interpreted language run slower. In addition, the efficiency is also lower in the process of explaining the article by clause.
Interpretive language also has advantages, such as its platform-independent, in addition, the specific explanation of the time will be dynamically optimized, and sometimes not much slower than the compiler type.
Python has a compilation process at the very beginning, so it is not a purely explanatory language like Java.
summed up, the so-called explanatory language is mainly three kinds:
1. Run the Advanced programming language directly: such as the Shell's built-in interpreter.
2. Convert the source code into some efficient bytecode or intermediate code and then explain the operation: e.g. PVM
3. Compile the source code into bytecode or intermediate code and instruct the processor to run the compiled program: for example, JIT
Reference blog:
http://blog.csdn.net/cdh1213/article/details/6919143
Http://www.cnblogs.com/lyhero11/p/5080306.html
Http://developer.51cto.com/art/201503/467055.htm
Differences between the C,c++,java and Python runtime interpreters and compilers