强vs静态打字和弱对比动态打字的区别 [英] Difference between Strong vs Static Typing AND Weak vs Dynamic Typing

查看:216
本文介绍了强vs静态打字和弱对比动态打字的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我所理解的是,动态类型与弱类型相同,强类型与静态类型相同。有什么不同?
谢谢

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

推荐答案

静态打字vs动态打字:



静态打字是在编译时发生类型检查。您必须定义一个在您的代码中输入您的变量,并且您对数据执行的任何操作都将由编译器检查。

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.

当您输入密码时,您只能在数据通过直接操纵该数据类型的对象。

弱键入允许您在不考虑其类型的情况下对数据进行操作。一些语言通过指针来做到这一点。在执行操作之前,其他语言会将您的一种类型转换为另一种。

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.

这篇关于强vs静态打字和弱对比动态打字的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆