Rainoftime
Links: https://www.zhihu.com/question/19918532/answer/21647195
Source: Know
Some of the concepts of the type system, the use of the more chaotic. Some things are not even strictly defined. The following is a relatively "strict" argument in academia. 1. First define some basic concepts program errorstrapped errors. Causes the program to terminate execution, such as an array in addition to 0,java access untrapped errors. Continue execution after an error, but any behavior may occur. such as buffer overflow in C, jump to error address forbidden behaviours Language design, you can define a set of forbidden behaviors. It must include all untrapped errors, but may contain trapped errors. Well behaved, ill behavedwell behaved: If the program execution is unlikely to occur forbidden behaviors, then the well behaved. Ill behaved: otherwise ill behaved ... 2. With the above concept, then discuss the strong, weak type, static, dynamic type strong, weakly type strong type strongly typed: If all programs in a language are well behaved--it is impossible to forbidden behaviors, Then the language is strongly typed. Weak type weakly typed: otherwise weakly typed. For example, the C language buffer overflow, belongs to the trapped errors, namely belongs to forbidden behaviors. So C is the weak type in front of the people also said, weak type language, type checking is less strict, such as biased towards tolerance implicit type conversion. For example, the C language int can be double. The result is that it is easy to produce forbidden behaviours, so it is a static type statically of a weakly typed dynamic, static type: behaved statically if the ill typed program is rejected at compile time; Dynamic type dynamiclly: If ill behaviors is rejected at run time, it is dynamiclly typed. 3. Misunderstanding people think C language to write int a, int b and so on, Python do not write (can directly write a, b), so C is static, Python is dynamic. This understanding is not accurate enough. For example, OCaml is static type, but it can not be explicitly written out. OCaml is a static implicitly typed static type that can be divided into two types: if the type is part of the language syntax, the explicit type is explicitly typed, and if the type isCompile-time derivation, which is implicity typed implicit types, such as ML and Haskell4. Here are some examples. No type: assembly weak type, static type: C + + weak type, dynamic type check: perl/php strong type, static type check: java/c# strong type, Dynamic type checking: Python, Scheme static explicit type: java/c static implicit type: Ocaml, Haskell
Differences between weakly-typed, strongly-typed, dynamic-type, static-type languages