Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a wrapper, a binding, and a port?

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

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?

like image 453
user478249 Avatar asked Dec 25 '11 05:12

user478249


People also ask

What is a wrapper and binding?

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

What does Port binding mean?

A port binding is the configuration information that determines where and how a message will be sent or received. Depending on its type, a port binding might refer to physical locations, pipelines, or other orchestrations.

What is a binding in coding?

In computer programming, to bind is to make an association between two or more programming objects or value items for some scope of time and place.

What is a language wrapper?

Wrappers can be individual software components, independent software products, software architectures, classes in object-oriented programming, or frameworks. If you want to use functions or code blocks of another programming language within a program, you can encapsulate them using a wrapper.


1 Answers

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

Pros:

  • It's in the same language as the original
  • Wrappers enhance or reuse functionality without needing a full rewrite.
  • Relatively quick to accomplish
  • Trivial updates when the source library changes. You'll probably only need to bind new functions unless they broke backwards compatibility by changing expected input/outputs of functions/classes.

Cons:

  • Wrapping an entire library can be extremely repetitive

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.

Pros:

  • Bring functionality from another language into the language of your choice.
  • Relatively fast in comparison to a port
  • Same level of trivial changes are needed as in wrapping- You'll probably only need to wrap new functions/classes unless they broke backwards compatibility by changing expected input/outputs of functions/classes.

Cons:

  • Just as repetitive as a wrapper
  • You're probably taking a fairly large performance hit, especially any wrapper involving an interpreted language on either end

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.

Pros:

  • Gives you the opportunity to make improvements to the code base as you see inadequacies
  • You'll be intimately familiar with HOW the code runs, not just what it does.

Cons:

  • By far the lengthiest solution in terms of time/requires a complete rewrite
  • You need to make sure that whatever functionality the source library needs in a language is available in your target port language or you'll end up wrapping needed functionality (and potentially defeating the purpose.)
  • Every time the source library updates, you have to update too by translating whatever changes they made or risk falling behind.
like image 146
odgrim Avatar answered Oct 04 '22 19:10

odgrim