包装器,绑定器和端口之间有什么区别? [英] What is the difference between a wrapper, a binding, and a port?

查看:88
本文介绍了包装器,绑定器和端口之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在软件可移植性上下文中,这三个概念之间有什么区别?

In a software portability context, what is the difference between these three concepts?

例如,我想使用 ncurses 库,则编写了原始的ncurses库在C中,但是我的应用程序是用C ++编写的,然后我发现"ncurses包装器",与ncurses的绑定"和"ncurses端口".我应该使用哪一个?

For example, I want to use the ncurses library, the original ncurses library is written in C, but my application is being written in C++, and then I found "ncurses wrapper", "bindings to ncurses", and "ncurses port". Which one should I use?

每个人的利弊是什么?

推荐答案

一个包装器是位于其他代码之上的少量代码可以回收其功能,但具有不同的接口.这通常意味着使用相同语言编写的界面.还应该注意的是,有时候人们会在技术上讲绑定(包括我自己)时说包装器.

A wrapper is a bit of code that sits on top of other code to recycle it's functionality but with a different interface. This usually implies an interface written in the same language. It should also be noted that sometimes people will say wrapper when what they technically mean is a binding (myself included).

优点:

  • 与原始语言相同
  • 包装程序可增强或重用功能,而无需完全重写.
  • 相对较快地完成
  • 源库更改时,临时更新.除非它们通过更改功能/类的预期输入/输出打破了向后兼容性,否则您可能仅需要绑定新功能.

缺点:

  • 包装整个库可能是非常重复的

绑定是位于其他代码之上的另一部分代码,以回收其功能除了这次绑定是用不同于绑定的语言编写的.一个值得注意的例子是PyQt,它是QT的python绑定.

A binding is another bit of code that sits on top of other code to recycle it's functionality except this time bindings are written in a language different than the thing they bind. A notable example is PyQt which is the python binding for QT.

优点:

  • 将其他语言的功能引入您选择的语言.
  • 与端口相比相对较快
  • 包装时需要进行相同级别的微不足道的更改-您可能只需要包装新的函数/类,除非它们通过更改期望的函数/类的输入/输出破坏了向后兼容性.

缺点:

  • 就像包装一样重复
  • 您可能会受到相当大的性能影响,尤其是两端都涉及解释语言的任何包装器

端口是指您翻译一些代码以在其他环境中工作时.常见的比喻包括游戏,比如说XBox,后来又在PS3上发布.

A Port is when you translate some code to work in a different environment. Common analogies include games that come out for say... XBox and are later released for PS3.

优点:

  • 当您看到不足之处时,会给您机会来改进代码库
  • 您将非常熟悉代码的运行方式,而不仅是代码的运行方式.

缺点:

  • 到目前为止,这是时间最长的解决方案/需要完整的重写
  • 您需要确保目标端口语言中提供了源库所需的某种语言功能,否则您将最终包装所需的功能(并有可能破坏目的).
  • 每次更新源库时,您都必须通过翻译它们所做的任何更改或可能落在后面的更新来进行更新.

这篇关于包装器,绑定器和端口之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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