静态/动态类型语言 & 强/弱类型语言
2017-05-24 10:56
507 查看
来自
静态类型语言比较不容易出差错,很多问题能提前检查出来。而动态语言比较灵活,用起来比较浪
In a statically typed language the type is static, meaning once you set a variable to a type, you CANNOT change it. That is because typing is associated with the value rather than the variable. (静态类型语言中类型与变量是一个整体)
For example in Java:
Whereas in a dynamically typed language the type is dynamic, meaning after you set a variable to a type, you CAN change it. That is because typing is associated with the value rather than the variable. (动态类型语言中类型与值是一个整体)
For example in Python:
For example in Python:
whereas in PHP:
静态/动态类型语言
Static/Dynamic typing is about when type information is aquired (Either at compiletime or at runtime)静态类型语言比较不容易出差错,很多问题能提前检查出来。而动态语言比较灵活,用起来比较浪
In a statically typed language the type is static, meaning once you set a variable to a type, you CANNOT change it. That is because typing is associated with the value rather than the variable. (静态类型语言中类型与变量是一个整体)
For example in Java:
String str = "Hello"; //statically typed as string str = 5; //would throw an error since java is statically typed
Whereas in a dynamically typed language the type is dynamic, meaning after you set a variable to a type, you CAN change it. That is because typing is associated with the value rather than the variable. (动态类型语言中类型与值是一个整体)
For example in Python:
str = "Hello" # it is a string str = 5 # now it is an integer; perfectly OK
强/弱类型语言
Strong/Weak typing is about how strictly types are distinguished (e.g. whether the language tries to do implicit conversion from strings to numbers).For example in Python:
str = 5 + "hello" # would throw an error since it does not want to cast one type to the other implicitly.
whereas in PHP:
$str = 5 + "hello"; // equals 5 because "hello" is implicitly casted to 0 // PHP is weakly typed, thus is a very forgiving language.
相关文章推荐
- 动态类型语言&静态类型语言
- 关于动态语言和静态语言、强类型定义语言和弱类型定义语言的概念区分
- 动态语言&静态语言
- 静态语言和动态语言、强类型和弱类型
- 编译型与解释型、动态语言与静态语言、强类型语言与弱类型语言的区别
- 关于动态语言和静态语言、强类型定义语言和弱类型定义语言的概念区分
- 动态语言和静态语言 | 强类型语言和弱类型语言
- 动态语言与静态语言、强类型与弱类型
- 静态语言、动态语言、强类型语言、弱类型语言
- 编译型与解释型、动态语言与静态语言、强类型语言与弱类型语言的区别
- 动态语言和静态语言、强类型定义语言和弱类型定义语言的概念区分
- 编译型与解释型、动态语言与静态语言、强类型语言与弱类型语言的区别
- 编译型与解释型、动态语言与静态语言、强类型语言与弱类型语言的区别
- 用近似静态语言、强类型语言的TypeScript开发属于动态语言、弱类型语言的JavaScript
- dedeeims 设置栏目访问类型(静态&动态)
- 四大类型的语言,动态,静态,强类型,弱类型
- 动态语言和静态语言、强类型定义语言和弱类型定义语言
- 编译型与解释型、动态语言与静态语言、强类型语言与弱类型语言的区别
- 动态语言,静态语言,动态类型语言,静态类型语言,动态编程语言,静态编程语言(未完)
- 动态语言和静态语言、强类型定义语言和弱类型定义语言、解释型语言、动态语言、脚本语言的概念区分