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

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

问题描述

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

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?

每种方法的优缺点是什么?

What are the pros and cons of each one?

推荐答案

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

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).

优点:

  • 它与原始语言使用相同的语言
  • 包装器无需完全重写即可增强或重用功能.
  • 完成速度相对较快
  • 源库更改时的微不足道的更新.您可能只需要绑定新函数,除非它们通过更改函数/类的预期输入/输出破坏了向后兼容性.

缺点:

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

binding 是位于其他代码之上以回收其功能的另一段代码除了这次绑定是用不同于它们绑定的东西的语言编写的.一个值得注意的例子是 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天全站免登陆