
In
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, a shim is a
library
A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
that
transparently intercepts
API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
calls and changes the arguments passed, handles the operation itself or redirects the operation elsewhere. Shims can be used to support an old API in a newer environment, or a new API in an older environment. Shims can also be used for running programs on different software platforms than they were developed for.
Shims for older APIs typically come about when the behavior of an API changes, thereby causing compatibility issues for older applications which still rely on the older functionality; in such cases, the older API can still be supported by a thin
compatibility layer
In software engineering, a compatibility layer is an interface that allows binaries for a legacy or foreign system to run on a host system. This translates system calls for the foreign system into native system calls for the host system. With so ...
on top of the newer code. Shims for newer APIs are defined as: "a
library
A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
that brings a new API to an older environment, using only the means of that environment."
Examples
* Web
polyfills implement newer
web standard
Web standards are the formal, non-proprietary standards and other technical specifications that define and describe aspects of the World Wide Web. In recent years, the term has been more frequently associated with the trend of endorsing a set of st ...
s using older standards and
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, if the newer standard is not available in a given
web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
.
* Support of
AppleTalk
AppleTalk is a discontinued proprietary suite of networking protocols developed by Apple Computer for their Macintosh computers. AppleTalk includes a number of features that allow local area networks to be connected with no prior setup or the ...
on
Macintosh
The Mac (known as Macintosh until 1999) is a family of personal computers designed and marketed by Apple Inc. Macs are known for their ease of use and minimalist designs, and are popular among students, creative professionals, and software en ...
computers, during the brief period in which
Apple Computer
Apple Inc. is an American multinational technology company headquartered in Cupertino, California, United States. Apple is the largest technology company by revenue (totaling in 2021) and, as of June 2022, is the world's biggest company ...
supported the
Open Transport
Open Transport was the name given by Apple Inc. to its implementation of the Unix-originated System V STREAMS networking stack. Based on code licensed from Mentat's Portable Streams product, Open Transport was built to provide the classic Mac OS ...
networking system. Thousands of Mac programs were based on the AppleTalk protocol; to support these programs, AppleTalk was re-implemented as an OpenTransport "stack", and then re-implemented as an API shim on top of this new library.
* The
Microsoft Windows Application Compatibility Toolkit (ACT) uses the term to mean
backward compatible
Backward compatibility (sometimes known as backwards compatibility) is a property of an operating system, product, or technology that allows for interoperability with an older legacy system, or with input designed for such a system, especially ...
libraries. Shims simulate the behavior of older versions of Windows for legacy applications that rely on incorrect or deprecated functionality, or correct the way in which poorly written applications call unchanged APIs, for example to fix
least-privileged user account (LUA) bugs.
* bind.so is a shim library for
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
that allows any application, regardless of permissions, to bind to a listening socket or specify outgoing IP address. It uses the
LD_PRELOAD
In computing, a dynamic linker is the part of an operating system that loads and links the shared libraries needed by an executable when it is executed (at " run time"), by copying the content of libraries from persistent storage to RAM, fillin ...
mechanism, which allows shims and other libraries to be loaded into any program.
* In the ''type tunnel'' pattern, a generic interface layer uses a family of shims to translate a heterogeneous set of types to a single primitive type used by an underlying API.
See also
*
Adapter pattern
In software engineering, the adapter pattern is a software design pattern (also known as Wrapper function, wrapper, an alternative naming shared with the decorator pattern) that allows the interface (computer science), interface of an existing clas ...
*
Application virtualization
Application virtualization is a software technology that encapsulates computer programs from the underlying operating system on which they are executed. A fully virtualized application is not installed in the traditional sense, although it is sti ...
*
Driver wrapper
A driver wrapper is a subroutine in a software library that functions as an adapter between an operating system and a driver, such as a device driver, that was not designed for that operating system. It can enable the use of devices for which no d ...
*
Glide wrapper
Glide is a 3D graphics API developed by 3dfx Interactive for their ''Voodoo Graphics'' 3D accelerator cards. Although it originally started as a proprietary API, it was later open sourced by 3dfx. It was dedicated to rendering performance, sup ...
*
Glue code
Adhesive, also known as glue, cement, mucilage, or paste, is any non-metallic substance applied to one or both surfaces of two separate items that binds them together and resists their separation.
The use of adhesives offers certain advant ...
*
Stub (computer science) A method stub or simply stub in software development is a piece of code used to stand in for some other programming functionality. A stub may simulate the behavior of existing code (such as a procedure on a remote machine; such methods are often cal ...
*
Thunk (compatibility mapping)
In computer programming, a thunk is a subroutine used to inject a calculation into another subroutine. Thunks are primarily used to delay a calculation until its result is needed, or to insert operations at the beginning or end of the other subro ...
*
Windows on Windows
In computing, Windows on Windows (commonly referred to as WOW), was a compatibility layer of 32-bit versions of the Windows NT family of operating systems since 1993 with the release of Windows NT 3.1, which extends NTVDM to provide limited su ...
(WoW)
*
Wrapper library
Wrapper libraries (or library wrappers) consist of a thin layer of code (a " shim") which translates a library's existing interface into a compatible interface. This is done for several reasons:
* To refine a poorly designed or complicated interfa ...
References
{{reflist, 30em
External links
Microsoft Dev-Center - Windows 8 Client and Server 2012 application CompatibilityMicrosoft TechNet - Understanding Shims
Application programming interfaces
Compatibility layers