Difference between Strong vs Static Typing AND Weak vs Dynamic Typing

蓝咒 提交于 2019-12-03 01:37:52

问题


From What I understand, does is dynamic typing the same as weak typing and strong typing is the same as static typing. Whats the difference? Thanks


回答1:


Static typing vs dynamic typing:

Static typing is when your type checking occurs at compile time. You must define a type for your variables inside of your code and any operations you perform on your data would be checked by the compiler.

Dynamic typing is when your type checking occurs at runtime. Instead of errors coming up when you compile your code you will get runtime errors if you try performing operations on incompatible types. However, you will get the benefit of having more versatile functions as they can be written once for multiple data types.

Strong typing vs weak typing:

When you have strong typing, you will only be allowed operations on the data by direct manipulation of the objects of that data type.

Weak typing allows you to operate on data without considering its type. Some language do this through pointers. Other languages will convert one of your types to the other before performing the operations.

The links I included have a bit more detailed (and probably clearer) explanations.



来源:https://stackoverflow.com/questions/11889602/difference-between-strong-vs-static-typing-and-weak-vs-dynamic-typing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!