Compiled language
Compiled languages, like assembly languages, have a translator that converts the source code we write to produce the corresponding executable code. This process is technically known as Compile, and the program responsible for compiling is naturally called a Compiler.
If the code we write is contained in a source file, it will usually be compiled to produce a specific file that we can run directly. However, for a complex project, we usually organize the code in various source files as different modules for easy management. When compiling each File, Object files are generated instead of executable files.
Generally, compilation of a source file corresponds to an object file. The contents of the object file are basically executable code, but they are only part of the whole project, so we can’t run them directly. Once all the source files are compiled, we can finally package the semi-finished object files into an executable. This work is done by another program, which is called a Link because it assembles objects containing executable code, and the program responsible for linking is naturally called a Linker.
In addition to linking object files, the linker may also have to manage various resources, such as icon files, sound files and so on, and be responsible for removing redundant and repetitive code between object files. In fact, the linker is not easy. But once the link is complete, we usually have the executable we want.
Interpretive language
Literally, compilation and interpretation both mean translation, but the difference lies in the timing of translation.
For example, if you want to read a foreign text and you don’t know the language, you can find a translator, give him enough time to translate the whole book from beginning to end, and then hand the book to you in your native language. Or you can ask the translator to help you read right away, sentence by sentence, and if you want to go back to a chapter, he has to do the same for you. These two translation methods, the former is equivalent to compiled language, the latter is equivalent to interpreted language.
Compiled languages translate all the code into machine language at once and write it as an executable.
Interpreted language is also only moments before the program to run the source code without executable file, each execution to the source code of a particular instruction, there will be a shell called the interpreter converts source code into a binary code for execution, that is, to explain, execution, interpretation, execution, interpretation, execution… Very much like life. Therefore, interpretive languages are inseparable from interpreters. BASIC, for example, was a classic interpreted language. To execute BASIC programs, you had to go into BASIC, load the source files, and run them.
A comparison of compiled and interpreted languages
Because programs written in interpreted languages always appear as source code, migration is rarely a problem as long as the corresponding interpreter is available. Compiled language programs, although the source code can be transplanted, but the premise is that they must be compiled separately for different environments. For complex projects, it is indeed a not small time consumption, let alone some details of the place or to modify the source code.
In addition, interpreted language because of the compilation of the step, modification debugging will be very convenient, after editing can run immediately, do not have to wait for a long Compling like compiled language every small change… Linking… This is the process of compiling links. However, everything has pros and cons, because the interpreted language is the compilation process into the execution process, which determines that the interpreted language is destined to be a lot slower than the compiled language, like hundreds of times the speed gap is not surprising.
Compiled and interpreted languages have their own advantages and disadvantages. The former because of the program execution speed, under the same conditions of low system requirements, so the development of operating system, large applications, database systems will use it, like C/C++, Pascal/Object Pascal (Delphi), VB and other languages can be regarded as compiled language. Some web scripts, server scripts and auxiliary development interfaces, such as speed requirements are not high, compatibility between different system platforms have certain requirements of the program is usually used in interpreted languages, such as Java (think about why, heh heh), JavaScript, VBScript, Perl and Python are interpreted languages.
Because compiled and interpreted languages have their own strengths and weaknesses and are opposed to each other, many emerging languages tend to combine the two trade-offs. For example, the Java language, although close to the characteristics of an interpreted language (running on the JVM virtual machine), is pre-compiled before execution. The generated code is intermediate code between machine code and Java source code, and is interpreted and executed by the JVM(Java’s virtual machine platform, which can be regarded as an interpreter) at runtime. It retains the high abstraction and portability of the source code, but it has already done most of the precompilation of the source code, so it is much faster than pure interpreted languages.
As design techniques and hardware evolve, the distinction between compiled and interpreted languages is blurring.
conclusion
Compiled languages: fast, efficient, compiler dependent, and less cross-platform.
Interpreted languages: slow, inefficient, interpreter dependent, cross-platform performance.