Binding (computer science)

From Wikipedia, the free encyclopedia

In computer science, binding is the creation of a simple reference to something that is larger and more complicated and used frequently. The simple reference can be used instead of having to repeat the larger thing. A binding is such a reference.

Contents

[edit] Types of binding

The following are commonly referred to as bindings.

[edit] Language or Name binding

Main articles: Name binding and Language binding

The terms language binding and name binding refer to both the linking of libraries to application programs, and to the way symbols (variable names) are handled by compilers.

In programming languages, these terms mean the references of an identifier to a value. In this context, binding is the act of associating a name or symbol with a machine address, and this association may occur either at compile time, in which case it is called 'static linking', or it may occur dynamically at runtime, which is called 'dynamic linking'. The terms binding and linking are used interchangeably in some contexts.

A real-life example of dynamic linking or binding is that one may know that some event will occur in a certain building (and one knows the building name), but one does not bother to look up the address of the building or find it on a map until right before the event is scheduled to begin. Likewise in software, while a program is already running (and perhaps long after it was compiled), it may receive an address and transfer execution to that address; that would be 'runtime binding'.

Dynamic link libraries (.DLL's in Windows, and dynamic libraries on Linux, for example) are typically 'bound' at runtime. This can be called 'late binding' (as opposed to 'early binding' at, say, compile time). Since the binding of a specific library will normally occur only upon first use during a program run (and not at all unless needed), that strategy (of not binding at all unless really needed) is also sometimes called 'lazy binding'.

Windows, Unix and Linux operating systems conserve memory and cycles by adopting a late (and lazy) binding approach as the default. Binding time (static vs. dynamic) linking can usually be overridden and made static by a programmer at compile time; this would make an executable file larger (all libraries would be sucked into it), but possibly would make it more reliable (due to avoiding the risk of a binding failure at runtime).

Static binding has an additional characteristic, which is that it prevents libraries from being updated (recompiled) independently of applications.

[edit] XML data binding

Main article: XML data binding

[edit] Command binding

Command bindings, commonly referred to as keyboard macros, or simply macros, are frequently built into professional quality computer applications. In many of these, bindings can be modified or added, but usually can not be removed (i.e., the keystroke combination cannot be unassociated from the function with which it is associated).

As an example of a command binding, most applications on Mac OS bind the "Save" menu item to the Command-S keyboard shortcut, so that Command-S can be used to save a document instead of having to navigate to that menu item each time. The Emacs text editor binds the "save-buffers-kill-emacs" command to the Control-X Control-C keystrokes in sequence, so that the user does not have to type "save-buffers-kill-emacs" whenever he wants to save and quit. Some computer applications, such as Microsoft Excel, allow the user to create a macro to do several common operations in sequence, and then bind a simple command to that macro to activate it.

[edit] Control binding

Control bindings in video games. A game might have a "shoot" control, which can be bound to any available key. A game like Tribes with complicated in-game menus can bind specific sequences of keys as shortcuts to menu items.

[edit] See also

In other languages