动态加载和后期绑定有何异同?

发布于 2024-11-26 21:33:00 字数 343 浏览 0 评论 0原文

来自维基百科:

动态加载是一种机制,计算机程序可以在运行时将库(或其他二进制文件)加载到内存中,检索函数的地址并库中包含的变量,执行这些函数或访问这些变量,然后从内存中卸载库。

后期绑定是一种计算机编程机制,其中在运行时按名称查找对象上调用的方法。


在我看来,

相似之处在于它们都是在运行时查找方法的机制。

不同之处在于,动态加载在运行时加载库后不需要使用链接器,但后期绑定始终需要链接器。

我不确定我是否正确,尤其是差异部分。我想从您的分析中了解更多信息。

From wikipedia:

Dynamic loading is a mechanism by which a computer program can, at run time, load a library (or other binary) into memory, retrieve the addresses of functions and variables contained in the library, execute those functions or access those variables, and unload the library from memory.

Late binding is a computer programming mechanism in which the method being called upon an object is looked up by name at run-time.


In my opinion,

A similarity is they are both mechanisms in which methods are looked up at run-time.

A difference is dynamic loading does not need to use a linker after loading the library at run-time but late binding always need a linker.

I'm not sure if I am correct, especially the difference part. I would like to learn more from your analysis.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

涫野音 2024-12-03 21:33:00

后期绑定,很像过度使用,是一种以牺牲正确性和可能的​​后期灾难性失败为代价来挤出一些额外好处(性能/内存限额)的黑客行为。

如果没有后期绑定,只有在加载时可以解析重定位所需的所有符号时,模块的动态加载才会成功,并且您会收到一个有意义的错误,如果无法解析这些错误,您可以从中恢复。通过后期绑定,动态加载实际上总是“成功”,然后当动态加载的模块尝试引用无法解析的符号时,程序可能会崩溃。

Late binding, much like overcommit, is a hack to squeeze out some extra benefit (performance / memory allowance) at the expense of correctness and possible late catastrophic failure.

Without late binding, dynamic loading of modules will succeed only if all symbols needed for relocation can be resolved at load time, and you get a meaningful error from which you can recover if they can't be resolved. With late binding, dynamic loading virtually always "succeeds", then can crash your program later when the dynamic loaded module tries to reference a symbol that can't be resolved.

风为裳 2024-12-03 21:33:00

据我了解,动态加载是比后期绑定更低的级别。因此,后期绑定函数调用看起来和感觉就像普通函数调用一样,除了如果缺少库,那么应用程序将在尝试调用时终止,而不是在应用程序启动时终止,而对于动态加载,您必须编写更多代码但您可以进行错误处理,例如调用后备方法。

As I understand it, dynamic loading is a lower level than late binding. So a late bound function call looks and feels just like an ordinary function call, except that if the library is missing then the application will terminate when the call is attempted instead of when the application launches, while for dynamic loading you have to write more code but you get to do error handling, such as calling a fallback method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文