Library
Library
A collection of reusable code. Unlike a framework, it does not dictate the control flow.
Library
A collection of reusable code. Unlike a framework, it does not dictate the control flow.
A library is a collection of reusable code that performs a specific function. It is a collection of code in which functions developers frequently use are implemented in advance, and which can be called and used when needed. Using a library allows you to reuse verified code without implementing complex functionality yourself, which can greatly shorten development time and improve code quality.
The history of libraries begins in the early days of programming. The mathematical function libraries of FORTRAN in the 1950s were an early form, and the concept of code reuse was established with the emergence of the C standard library (libc). Class libraries appeared along with the development of object-oriented programming in the 1990s, and since the 2000s the library ecosystem has grown explosively with the open-source movement and the development of package managers.
The key difference between a library and a framework is Inversion of Control (IoC). A library is a tool that the developer calls when needed, whereas a framework controls the flow of the entire application and calls the developer's code. For example, React is a library for building UI components, while Next.js and Angular are frameworks that define the structure and flow of an application. The Hollywood principle, "Don't call us, we'll call you," explains this difference well.
In modern development, libraries are managed through a package manager. npm (Node Package Manager) in the JavaScript ecosystem provides more than 1 million packages, and Python's pip and PyPI, as well as Java's Maven Central, also host hundreds of thousands of libraries. These tools automate dependency resolution, version management, and security vulnerability scanning, helping developers use libraries efficiently.
# pip install requests λ‘ μ€μΉ
import requests
# GET μμ² - APIμμ λ°μ΄ν° κ°μ Έμ€κΈ°
response = requests.get('https://api.github.com/users/octocat')
# μλ΅ μν νμΈ
if response.status_code == 200:
data = response.json()
print(f"μ¬μ©μ: {data['login']}")
print(f"νλ‘μ: {data['followers']}")
# POST μμ² - λ°μ΄ν° μ μ‘νκΈ°
payload = {'title': 'μ κΈ', 'body': 'λ΄μ©μ
λλ€'}
response = requests.post(
'https://jsonplaceholder.typicode.com/posts',
json=payload,
headers={'Content-Type': 'application/json'}
)
// npm install lodash λ‘ μ€μΉ
import _ from 'lodash';
// λ°°μ΄ μμ
μ νΈλ¦¬ν°
const users = [
{ 'name': 'κΉμ² μ', 'age': 30, 'active': true },
{ 'name': 'μ΄μν¬', 'age': 25, 'active': false },
{ 'name': 'λ°λ―Όμ', 'age': 35, 'active': true }
];
// 쑰건μ λ§λ μμ μ°ΎκΈ°
const activeUsers = _.filter(users, { 'active': true });
// κ²°κ³Ό: [{ name: 'κΉμ² μ', ... }, { name: 'λ°λ―Όμ', ... }]
// λ°°μ΄ κ·Έλ£Ήν
const grouped = _.groupBy(users, 'active');
// κΉμ λ³΅μ¬ (Deep Clone)
const clonedUsers = _.cloneDeep(users);
// λλ°μ΄μ€ - μ°μ νΈμΆ λ°©μ§
const debouncedSearch = _.debounce((query) => {
console.log(`κ²μ: ${query}`);
}, 300);
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free
Each license, such as MIT, Apache 2.0, and GPL, has different terms of use. Using a GPL library in a commercial project may create an obligation to disclose the source code, so be sure to check the license before adopting it in your project.
External libraries are a major pathway for security vulnerabilities. Use npm audit, pip-audit, Dependabot, Snyk, and similar tools to check for vulnerabilities regularly, and update promptly when security patches are released.
Major version upgrades may include breaking changes. Pin versions with package-lock.json, requirements.txt, and similar files, and update safely by understanding Semantic Versioning (SemVer).