compiler language, interpretive language, static type language, dynamic type language concepts and differences

Source: Internet
Author: User

Dynamic Language: Modify the structure;

Dynamic type: Run-time type checking;

Compiler language: machine code, interpreter;

Strongly typed: The type is immutable.

Compiled and interpreted languages 1, compiled languages

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.
Representative languages: JavaScript, Python, Erlang, PHP, Perl, Ruby

3. Mixed-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.
Main dynamic languages: Object-c, C #, JavaScript, PHP, Python, Erlang.

2. Static language

In contrast to dynamic languages, the immutable language of the runtime structure is static. such as Java, C, C + +.

3. Note:

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.
Major languages: Python, Ruby, Erlang, JavaScript, Swift, PHP, Perl.

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.

3. Note:

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 languages and weakly typed languages 1, strongly typed languages:

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.
Major languages: JavaScript, PHP, C, C + + (c and C + + are controversial, but it is possible to give a character variable an integer value that might have been strongly typed and nearly weakly typed in form)

3. Note:

A language is not a strongly typed language and is not necessarily associated with a dynamic type language. Python is a dynamic type language and is a strongly typed language. JavaScript is a dynamic type language and is a weakly typed language. Java is a statically typed language and is a strongly typed language.

Recently saw an article about static dynamic, strong and weak types of articles thought to be reproduced in detail, referring to the original address of the article Utm_medium=referral

compiler language, interpretive language, static type language, dynamic type language concepts and differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.