What is a language binding?
Asked Answered
H

4

68

My good friend, Wikipedia, didn't give me a very good response to that question. So:

  • What are language bindings?
  • How do they work?

Specifically accessing functions from code written in language X of a library written in language Y.

Hardison answered 25/8, 2008 at 11:13 Comment(0)
S
45

Let's say you create a C library to post stuff to stackoverflow. Now you want to be able to use the same library from Python. In this case, you will write Python bindings for your library.

Also see SWIG: http://www.swig.org

Stopping answered 25/8, 2008 at 11:33 Comment(0)
C
25

In the context of code libraries, bindings are wrapper libraries that bridge between two programming languages so that a library that was written for one language can also be implicitly used in another language.

For example, libsvn is the API for Subversion and was written in C. If you want to access Subversion from within Java code you can use libsvn-java. libsvn-java depends on libsvn being installed because libsvn-java is a mere bridge between the Java programming language and libsvn, providing an API that merely calls functions of libsvn to do the real work.

Censure answered 25/8, 2008 at 11:26 Comment(3)
So "binding" simply means that it's an "interface". Only that they didn't call it 'interface' because it's in a different language. "Binding" is just an adjective that says that there the same function calls of one language are now being supported by function calls of another language. Cool! Is there any website which explains the implementation details of how the bridge between two languages is created?Lying
I'm sorry for reviving such an old answer, but I was wondering if there is any performance loss when using language bindings? (I can't find a lot of information online)Orangeman
@Orangeman I wanted to ask the same thing before I saw you asked it. And you asked it almost 10 years agoCalore
P
5

Okay, now the question has been clarified, this isn't really relevant so I'm moving it to a new question

Binding generally refers to a mapping of one thing to another - i.e. a datasource to a presentation object. It can typically refer to binding data from a database, or similar source (XML file, web service etc) to a presentation control or element - think list or table in HTML, combo box or data grid in desktop software.

...If that's the kind of binding you're interested in, read on...

You generally have to bind the presentation element to the datasource, not the other way around. This would involve some kind of mapping - i.e. which fields from the datasource do you want to appear in the output.

For more information in a couple of environments see:

Pug answered 25/8, 2008 at 11:24 Comment(0)
C
-1

In Flex (Actionscript 3). Source

A data binding copies the value of a property in one object to a property in another object. You can bind the properties of following objects: Flex components, Flex data models, and Flex data services.

The object property that provides the data is known as the source property. The object property that receives the data is known as the destination property.

The following example binds the text property of a TextInput component (the source property) to the text property of a Label component (the destination property) so that text entered in the TextInput component is displayed by the Label component:

<mx:TextInput id="LNameInput"></mx:TextInput>
...
<mx:Label text="{LNameInput.text}"></mx:Label>

Data binding is usually a simple way to bind a model to user interface components. For example, you have a class with a FirstName property. In flex you could easily bind that property to a textbox by setting the value of the textbox to {Object.FirstName}. Then, every time that FirstName property changes, the textbox will be updated without requiring you to write any code to monitor that property for changes.

Hope that helps.

Matt

Clisthenes answered 25/8, 2008 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.