Today I see a blog post that summarizes the static, dynamic, strong type, and weak types, under this mark.
Compiled and interpreted languages
1. Compiled language
The language in which the source code needs to be compiled into machine code and then executed by the compiler (compiler). Generally need to go through the compilation (compile), link (linker) These two steps. Compiling is to compile the source code into machine code, linking the machine code of each module and the dependent library to generate the executable file.
Pros: Compilers typically have pre-compiled procedures to optimize code. Because the compilation is done only once, the runtime does not need to compile, so the program execution of the compiled language is highly efficient. Can run independently from the language environment.
Cons: After compilation, the entire module needs to be recompiled if modifications are required. When compiling the machine code according to the corresponding running environment, porting between different operating systems will be problematic, and you need to compile different executables according to the operating system environment you are running.
Representative languages: C, C + +, Pascal, object-c and the latest Apple language Swift
2. Interpreted language
A program that interprets a language does not need to be compiled, but rather than a compiled language, the explanatory language is translated on a per-line basis when it runs the program.
Pros: Good platform compatibility, can be run in any environment, provided the interpreter (virtual machine) is installed. Flexible, modify the code when the direct modification can be quickly deployed, without downtime maintenance.
Cons: Every time you run, you have to explain it again, performance is not as good as the compiled language.
Since the compiler and interpretation of each have shortcomings will be thought of the two types of integration, take its essence to its dross. There is a semi-compiled language. For example, c#,c# in the compile time is not directly compiled into the machine code, but the middle code. NET platform provides intermediate language runtime Runtime Intermediate code, the intermediate language runtime is similar to a Java virtual machine. After the. NET is translated into Il code, it is saved in the DLL, the first run time is translated into the machine code by JIT in memory, the next direct execution (Bo friends reply). I personally think that the bias against everything C # is the best programming language on the planet. Unfortunately, Microsoft's policy limits the promotion of C #.
Mr. Java bytecode is then interpreted in the Java Virtual machine for execution.
Strictly speaking, the mixed language belongs to the interpretive language. C # is closer to the compiled language.
Dynamic language and static language
1. Dynamic language
is a class of languages that can change its structure at run time: New functions, objects, even code can be introduced, existing functions can be deleted or other structural changes. The popular point is that at runtime code can change its structure according to certain conditions.
2. Static language
In contrast to dynamic languages, the immutable language of the runtime structure is static. such as Java, C, C + +.
Many people think that interpreted language is a dynamic language, this view is wrong! Java is an interpreted language but not a dynamic language, and Java cannot change its structure at run time. Is it set up in reverse? Dynamic languages are interpreted languages. It's also wrong! Object-c is a compiled language, but he is a dynamic language. The OC code can be inserted and replaced at run time, thanks to the unique run time mechanism (that is, not that the syntax attribute is the runtime environment, which does not expand).
C # is also a dynamic language, and the reflection mechanism of C # can dynamically insert a piece of code execution. So I say C # is the best programming language on the planet.
dynamic type language and static type language
1. Dynamic type language
Many online materials confuse dynamic type language with dynamic language, which is fraught. Dynamic type languages and dynamic languages are two completely different concepts. Dynamic type language refers to the language in which data type checking is done during run time, that is, the data type, and the dynamic language is that the operation is to change the structure, that is, the code structure.
The data type of the dynamic type language is not determined during the compilation phase, but rather delays the type binding to the run phase.
2. Static type language
The data type of a static language is determined in the course of compilation or before it is run, and the data type of the variable is explicitly determined when writing the code.
Major languages: C, C + +, C #, Java, Object-c.
Quite a few programmers, including the one I used to think, interpreted languages are dynamic type languages, and compiled languages are static type languages. This is wrong, too. Swift is a compiled language, but it is also a dynamic type language. C # and Java are interpreted languages as well as statically typed languages.
Strongly typed and weakly typed languages
1. Strong type language:
Strongly typed language, once a variable is assigned a data type, it is always the data type if it is not cast by coercion. You cannot treat an integer variable as a string.
Major languages: Java, C #, Python, Object-c, Ruby
2. Weak type language:
Data types can be ignored, and a variable can assign values of different data types. Once you assign a string value to an integer variable A, a becomes a character type.
compiler language, interpretive language, static type language, dynamic type language concepts and differences