Framework
- In Turkish
- çatı
In short
A framework is a reusable foundation of code, tools, and conventions that provides the structure of an application, so developers only fill in their own logic.
What is a framework?
A framework gives you a ready-made skeleton for building a certain kind of software, such as a web app, a mobile app, or an API. It handles common, repetitive work like routing requests, rendering pages, or talking to a database, and it defines where your own code should go. This lets teams focus on the features that make their product unique.
The key idea behind a framework is inversion of control. With a library, your code is in charge and calls the library when it needs something. With a framework, the framework is in charge: it runs the application and calls your code at specific points, such as when a page loads or a request arrives.
Building a house is a helpful analogy for the difference. A library is like a hardware store where you pick the tools you need, while a framework is like a pre-built frame of walls and a roof that you finish and decorate. Well-known examples include Django, Ruby on Rails, and Spring for server-side development, and Angular and Next.js for building web applications.
Frameworks speed up development and encourage a consistent structure, but they come with trade-offs. You have to learn their conventions, follow their way of doing things, and keep up with version upgrades. Some tools blur the line: React describes itself as a library, yet many developers loosely call it a framework.
Key takeaways
- A framework provides the structure of an application; you fill in the details.
- Inversion of control: the framework calls your code, not the other way around.
- It handles common tasks like routing, rendering, and data access.
- Trade-offs include a learning curve and less freedom to do things your own way.
Example
// You register handlers; the framework decides when to call them
import express from "express";
const app = express();
// Called by the framework whenever a GET /hello request arrives
app.get("/hello", (req, res) => {
res.json({ message: "Hello, world!" }); // your own logic
});
app.listen(3000); // the framework now runs the serverReaders ask
What is the difference between a framework and a library?
With a library, your code decides when to call it. With a framework, the framework controls the flow and calls your code at defined points, which is known as inversion of control.
Is React a framework or a library?
React describes itself as a library for building user interfaces, because it focuses on rendering components and leaves concerns like routing and data fetching to other tools. Frameworks such as Next.js build on React to provide a complete application structure.
Do I need a framework to build a website?
No. You can build a website with plain HTML, CSS, and JavaScript. Frameworks become valuable as a project grows, because they provide structure and solve common problems for you.
Often compared
See also
- JavaScriptWeb Development, p. 24JavaScript is the programming language that runs in web browsers to make pages interactive, and it also runs on servers through runtimes like Node.js.
- MVCSoftware Architecture, p. 29MVC is an architectural pattern that splits an application into a Model for data and logic, a View for display, and a Controller that handles user input.
- SPAWeb Development, p. 41An SPA is a web application that loads a single HTML page and then updates content with JavaScript, so moving between views does not reload the page.
- SSRWeb Development, p. 43SSR is a technique where the server builds the full HTML for a page on each request, so users and search engines receive ready-to-read content immediately.
- Design PatternSoftware Architecture, p. 13A design pattern is a proven, reusable solution to a common problem in software design, described as a general template rather than as finished code.
- APIBackend & APIs, p. 2An API is a set of rules that lets one piece of software request data or actions from another in a predictable, documented way.
- LibraryProgramming Fundamentals, p. 34A library is a collection of ready-made code, such as functions and classes, that a program calls to do common jobs without writing that code itself.
Spotted a mistake or something missing on this page?Suggest an edit