language binding

{{Short description|Software library that allows using another library coded in another programming language}}

In programming and software design, a binding is an application programming interface (API) that provides glue code specifically made to allow a programming language to use a foreign library or operating system service (one that is not native to that language).

Characteristics

Binding generally refers to a mapping of one thing to another. In the context of software libraries, bindings are wrapper libraries that bridge two programming languages, so that a library written for one language can be used in another language.{{cite web|url=http://www.cairographics.org/manual/language-bindings.html |title=Appendix A. Creating a language binding for cairo |publisher=Cairographics.org |access-date=2014-04-02}} Many software libraries are written in system programming languages such as C or C++. To use such libraries from another language, usually of higher-level, such as Java, Common Lisp, Scheme, Python, or Lua, a binding to the library must be created in that language, possibly requiring recompiling the language's code, depending on the amount of modification needed.{{cite web |url=http://www.acm.org/tsc/apis.html |title=Standards, APIs, Interfaces and Bindings |publisher=Acm.org |access-date=2014-04-02 |archive-url=https://web.archive.org/web/20150116081559/http://www.acm.org/tsc/apis.html |archive-date=2015-01-16 |url-status=dead }} However, most languages offer a foreign function interface, such as Python's and OCaml's ctypes, and Embeddable Common Lisp's cffi and uffi.{{cite web|url=https://docs.python.org/3/library/ctypes.html |title=ctypes – A foreign function library for Python |work=Python v3.8.3 documentation |publisher=Docs.python.org |access-date=2020-06-04}}{{cite web

|url= https://realworldocaml.org/v1/en/html/foreign-function-interface.html

|title= Real Worl OCaml, Chapter 19. Foreign Function Interface

|year= 2013 |access-date= 2015-07-19

|last= Hickey |first= Jason |last2= Madhavapeddy |first2= Anil |last3= Minsky |first3= Yaron

|website= realworldocaml.org

}}{{cite web|url=http://common-lisp.net/project/cffi/manual/html_node/Introduction.html#Introduction |title=Introduction – CFFI User Manual |publisher=Common-lisp.net |access-date=2014-04-02}}

For example, Python bindings are used when an extant C library, written for some purpose, is to be used from Python. Another example is libsvn which is written in C to provide an API to access the Subversion software repository. To access Subversion from within Java code, libsvnjavahl can be used, which depends on libsvn being installed and acts as a bridge between the language Java and libsvn, thus providing an API that invokes functions from libsvn to do the work.{{cite web |url=http://subclipse.tigris.org/wiki/JavaHL |title=Subversion JavaHL FAQ |publisher=Subclipse.tigris.org |date=2013-06-18 |access-date=2014-04-02}}

Major motives to create library bindings include software reuse, to reduce reimplementing a library in several languages, and the difficulty of implementing some algorithms efficiently in some high-level languages.

Runtime environment

{{expand section|date=November 2016}}

=Object models=

{{Further|Object model}}

{{expand section|date=November 2016}}

=Virtual machines=

{{Further|Virtual machine}}

{{expand section|date=November 2016}}

Porting

{{Further|Porting}}

{{expand section|date=November 2016}}

See also

{{prose|date=November 2016}}

{{Portal|Computer programming}}

{{Div col|colwidth=50em}}

{{div col end}}

References

{{Reflist|30em}}