静态/动态类型VS静态/动态绑定 [英] statically/dynamically typed vs static/dynamic binding

查看:152
本文介绍了静态/动态类型VS静态/动态绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家是那些4方面的区别,您能不能给请的例子吗?

everyone what is the difference between those 4 terms, can You give please examples?

推荐答案

静态动态的是参考点,其中一些编程元素是时候行话词解决。 静态的指示解决发生在一个程序构建的时间。 动态的指示解决发生在程序运行的时间。

Static and dynamic are jargon words that refer to the point in time at which some programming element is resolved. Static indicates that resolution takes place at the time a program is constructed. Dynamic indicates that resolution takes place at the time a program is run.

键入的指程序的结构,是由于数据值之间的差异变化:整数,字符,浮点数,字符串,对象等。这些差异可以有很多效果,例如:

Typing refers to changes in program structure that are due to the differences between data values: integers, characters, floating point numbers, strings, objects and so on. These differences can have many effects, for example:


  • 内存布局(例如,4个字节的int,8字节双,多为对象)

  • 执行的指令(例如基本操作添加小整数,库调用添加路数)

  • 程序流程(简单的子程序调用约定与哈希派出多方法)

静态类型的意味着在构建时生成的程序的可执行形式将取决于在程序中发现的数据类型的值会有所不同。 动态类型的意思是产生code将始终是相同的,不论类型的 - 在执行中的任何差异将在运行时确定

Static typing means that the executable form of a program generated at build time will vary depending upon the types of data values found in the program. Dynamic typing means that the generated code will always be the same, irrespective of type -- any differences in execution will be determined at run-time.

请注意,很少有真正的系统要么纯粹是一个或另一个,这只是一个问题,哪些是preferred策略。

Note that few real systems are either purely one or the other, it is just a question of which is the preferred strategy.

绑定的指名的程序文本联想到它们所参考的存储位置。在静态绑定的,该协会是$ P $在构建时pdetermined。随着的动态绑定的,该协会没有确定,直到运行时。

Binding refers to the association of names in program text to the storage locations to which they refer. In static binding, this association is predetermined at build time. With dynamic binding, this association is not determined until run-time.

真正的静态绑定几乎绝迹。早期的汇编和FORTRAN,例如,将彻底precompute所有变量和子程序地点的确切存储位置。这种情况并没有持续多久,引进栈和堆分配的变量和动态加载库子程序。

Truly static binding is almost extinct. Earlier assemblers and FORTRAN, for example, would completely precompute the exact memory location of all variables and subroutine locations. This situation did not last long, with the introduction of stack and heap allocation for variables and dynamically-loaded libraries for subroutines.

所以,我们必须采取一些与自由的定义。它是这里计算概念的精神:静态绑定程序precompute尽可能多的有关存储布局是现代虚拟内存的实际,垃圾回收,单独编译应用程序。动态绑定的程序等待越晚越好。

So one must take some liberty with the definitions. It is the spirit of the concept that counts here: statically bound programs precompute as much as possible about storage layout as is practical in a modern virtual memory, garbage collected, separately compiled application. Dynamically bound programs wait as late as possible.

一个例子可能会有帮助。如果我试图调用方法 MyClass.foo(),静态绑定系统将验证在制作的时候,有一个叫做类 MyClass的和类有一个方法。动态绑定系统会等到运行时看到的要么是否存在。

An example might help. If I attempt to invoke a method MyClass.foo(), a static-binding system will verify at build time that there is a class called MyClass and that class has a method called foo. A dynamic-binding system will wait until run-time to see whether either exists.

静态策略的主要力量是程序翻译更加了解程序员的意图。这使得它更容易:

The main strength of static strategies is that the program translator is much more aware of the programmer's intent. This makes it easier to:


  • 捕获许多常见错误年初,在构建阶段

  • catch many common errors early, during the build phase

打造重构工具

招致确定只有一次程序的可执行形式所需的计算成本的一个显著量,在生成时

incur a significant amount of the computational cost required to determine the executable form of the program only once, at build time

动态战略的主要力量,他们更容易实现,这意味着:

The main strength of dynamic strategies is that they are much easier to implement, meaning that:


  • 工作动态环境可以在一个静态的成本的一小部分来创建

  • a working dynamic environment can be created at a fraction of the cost of a static one

这是更容易添加的语言特性,可能是​​非常具有挑战性的静态检查

it is easier to add language features that might be very challenging to check statically

更​​容易处理需要自我修改code的情况下

it is easier to handle situations that require self-modifying code

这篇关于静态/动态类型VS静态/动态绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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