Explain the difference between python compiler and interpreter in detail

  • 2021-07-01 07:39:50
  • OfStack

High-level languages cannot be directly understood and executed by machines, so they all need a translation stage. Interpretive languages use interpreters, while compiled languages use compilers.

The common execution process of compiled languages is: source code-preprocessor-compiler-object code-linker-executable program.

In a sense, preprocessing is actually an additional function, which can be added to C and PHP, among which preprocessing instructions are mostly header file inclusion, macro definition and so on. Because the core of macro definition is a word "change", preprocessing is to provide an environment for program execution.

Compiler-Object code is to convert a high-level programming language into a machine language that can be understood and executed by the machine.

One point should be understood before the function of linker begins to understand. Header files are compiled into individual files in the preprocessing process, that is, library files. The program is a separate file and is not included in the library file. So this requires a "glue" to connect the program and library to form an executable file (Windows is EXE). This is what the linker does.

Interpreter understanding is simple, the program 1 line of understanding, execution. First read 1 line of code, then execute the meaning of this 1 line of code, then read the next 1 line of code and execute the next line of code. 1 cycle.

The compiler reads all the code, packages it into an executable file, and executes it. Because we run 1 is generally compiled executable files, that is, executing machine language (and IDE optimized), so the running speed is faster than interpreted language.


Related articles: