Software Library
Also known as: Library, Code library
Collection of prewritten, reusable code, such as functions and classes, that programs call on to perform common tasks without reimplementing them.
A software library is a packaged collection of code that other programs can use. Instead of writing their own routines to parse dates, compress files, draw charts or encrypt data, programmers call functions from libraries written and tested by others. A library exposes an interface, the set of functions and types it makes available, and hides its internal details. Most languages ship with a standard library covering everyday needs, and many thousands of third-party libraries are distributed through package managers such as npm and pip.
Libraries predate high-level languages. Programmers of the EDSAC computer at Cambridge built up a library of reusable subroutines in the early 1950s, documented in a 1951 book by Maurice Wilkes, David Wheeler and Stanley Gill. Libraries can be linked statically, with their code copied into the final program, or dynamically, loaded at run time from shared files such as DLLs on Windows or .so files on Linux, so that many programs share one copy. A key distinction separates libraries from frameworks: a program calls a library when it chooses, whereas a framework calls the program's code.
Libraries are a major way programming knowledge accumulates, letting each project build on earlier work, and open source libraries form much of the foundation of commercial software. Dependence carries risks. A widely used library can harbor a flaw that affects countless applications, as happened with the Log4Shell vulnerability in the Log4j logging library in 2021, and compromised packages are a route for supply chain attacks. Projects manage these risks by pinning versions, tracking dependencies in a software bill of materials and applying security updates promptly.
Key points
- A library provides reusable, tested code that programs call through a defined interface.
- Static linking copies library code into a program, while dynamic linking loads shared code at run time.
- A program calls a library when it chooses, whereas a framework calls into the program's code.
- Vulnerabilities in popular libraries, such as Log4Shell in 2021, can affect enormous numbers of applications.
Related entries
Software Framework
Reusable software platform that provides a predefined structure and calls developer-written code at set points, shaping how an application is built.
Package Manager
Tool that automates installing, upgrading, configuring and removing software packages and their dependencies from shared repositories.
API
Defined set of rules and interfaces through which one piece of software can request services or data from another without knowing its internals.
Software Development Kit
Bundle of tools, libraries, documentation and samples that developers use to build software for a particular platform, device or service.
Open Source
Approach to software in which source code is published under a license that lets anyone inspect, modify and redistribute it.
Software Supply Chain Attack
Attack that compromises software by tampering with its dependencies, build systems or update channels, so trusted code delivers malicious changes to users.
Software Bill of Materials
Machine-readable inventory of the components, libraries and dependencies that make up a piece of software, used to track vulnerabilities and licenses.
Semantic Versioning
Versioning convention that encodes compatibility in MAJOR.MINOR.PATCH numbers, signaling breaking changes, added features and bug fixes.
Referenced by
Other entries that discuss or point to Software Library.