What is a framework?


Say you are building a small web app: accounts, a feed, a settings page. Before any of your own ideas appear on screen, you need code that turns URLs into pages, code that talks to a database, code that keeps passwords safe, and code that redraws the screen when something changes. None of that is your app's idea. Every app needs it, and most of it is the same from project to project.
You could write all of that plumbing yourself, and people did, for years. It is slow, it is where the subtle bugs live, and every team ended up with a slightly different, slightly broken version of the same machinery. A framework is the accumulated answer: the shared plumbing, written once and hardened by thousands of projects, packaged with a structure that tells you where your own code goes. You build the parts that make your project yours; the framework handles the parts every project repeats.
Frameworks are not a web thing. They exist everywhere programs get built, and this chapter is about the idea itself, in any language and any field.
What a framework is (and what a library is)
The word gets used loosely, so here is the distinction that actually matters, in code:
// A library: your code is in charge, and calls the library when useful.
const label = dateLibrary.format(order.createdAt, "MMM D");
// A framework: the framework is in charge, and calls the code you plug in.
export default function OrdersPage() {
return listOfOrders();
}The first line is you steering: your program runs, and it borrows a tool for one job. The second is different in kind. You never call OrdersPage yourself. You write it, put it where the framework expects, and the framework calls it at the right moment, here, when a visitor opens the orders page.
That flip has a name: inversion of control. With a library, your code controls the program's flow and borrows helpers. With a framework, the framework controls the flow, and your code fills in the blanks it leaves for you. A useful shorthand: you call a library; a framework calls you.
The same shape appears in every corner of programming. Django receives the web request and calls your view function. Flutter runs the app and asks your widgets what to draw. Unity runs the game loop and calls your scripts every frame. pytest finds your test functions and runs them for you. Different fields, one idea: the framework owns the engine, and you supply the parts it was built to hold.
If a picture helps: a library is a toolbox sitting beside you while you build, and you reach in whenever a tool is useful. A framework is closer to a building's frame, already standing when you arrive. The walls, wiring, and plumbing have their places, and your work goes into the rooms that make the building yours. Both save you effort; the difference is who decides the shape of the build.
What a framework buys you, and what it costs
The case for a framework is concrete. Problems that would take you weeks arrive already solved, and solved by people who hit the hard edge cases first: password handling, form validation, routing, rendering. Your project gets a structure that a new teammate can recognise in minutes, because it is the same structure as every other project on that framework. And you inherit an ecosystem: plugins, tutorials, answered questions, and a hiring pool of people who already know their way around.
The costs are equally concrete, and they deserve the same straight look. A framework is a large dependency you do not control, with its own bugs, its own pace, and its own opinions. There is a learning curve before your first page renders, and some of what you learn is knowledge about the framework rather than about programming. Your code bends to its shapes, which makes leaving harder the longer you stay. And frameworks move: major versions arrive, patterns get rethought, and keeping up is ongoing work you did not have as plain code.
Neither list wins on its own. The balance depends entirely on the project, so the question to ask of any framework is "does this one make this project simpler". A framework earns its place by making your project simpler. When it does, use it gladly. When it does not, the next two chapters are about recognising that early.
Where this goes next
With the idea in place, the natural next question is what is actually out there: The kinds of frameworks tours the major families, from web to games to testing, with the most popular options in each. After that, Choosing and learning a framework gets practical about picking one, learning one, and knowing when you need none at all. And if the JavaScript examples above felt unfamiliar, the JavaScript track covers the language itself, which is the right first step before any framework built on it.

