弱类型、强类型、动态类型、静态类型语言的区别是什么?
43 个回答
无图无真相,帮大神
@姚培森补图:
红色区域外:well behaved (type soundness)
红色区域内:ill behaved
如果所有程序都是灰的,strongly typed
否则如果存在红色的程序,weakly typed
编译时排除红色程序,statically typed
运行时排除红色程序,dynamically typed
所有程序都在黄框以外,type safe
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
参考:《Type Systems》 Luca Cardelli - Microsoft Research
Trapped error: An execution error that immediately results in a fault.
Untrapped error: An execution error that does not immediately result in a fault.
Forbidden error: The occurrence of one of a predetermined class of execution errors;
Typically the improper application of an operation to a value, such as not(3).
Well behaved: A program fragment that will not produce forbidden errors at run time.
Strongly checked language: A language where no forbidden errors can occur at run time (depending on the definition of forbidden error).
Weakly checked language: A language that is statically checked but provides no clear guarantee of absence of execution errors.
Statically checked language: A language where good behavior is determined before execution.
Dynamically checked language: A language where good behavior is enforced during execution.
Type safety: The property stating that programs do not cause untrapped errors.
Explicitly typed language: A typed language where types are part of the syntax.
Implicitly typed language: A typed language where types are not part of the syntax.