What Are Frameworks?

While libraries are tools you pick up and use, frameworks are more like pre-built structures you move into and customize. A framework provides the scaffolding, patterns, and conventions for building applications — you fill in the specific details.

The Key Difference: Inversion of Control

With a library, you call the library's code. You're in control of the program flow.

With a framework, the framework calls your code. The framework controls the overall flow, and you provide specific pieces that plug into its structure.

Think of it like the difference between cooking from scratch versus using a meal kit. With scratch cooking (libraries), you decide everything — what to make, what order, what techniques. With a meal kit (framework), the structure is provided — you just add the specific ingredients where indicated.

What Frameworks Provide

Frameworks typically include:

  • Application structure: Where files go, how code is organized
  • Common patterns: Standard ways to handle routing, data, authentication
  • Built-in functionality: Features you'd otherwise build yourself
  • Conventions: Agreed-upon ways of doing things that reduce decisions
# Flask framework example - you define the function,
# the framework calls it when someone visits /hello
from flask import Flask
app = Flask(__name__)

@app.route('/hello')
def hello():
    return 'Hello, World!'

You wrote the hello() function, but Flask decides when to call it based on incoming web requests.

Different types of applications have different frameworks:

  • Web backends: Django, Flask (Python); Express (Node.js); Rails (Ruby)
  • Web frontends: React, Vue, Angular (JavaScript)
  • Mobile apps: React Native, Flutter

Tradeoffs

Frameworks boost productivity by handling common tasks and enforcing consistency. But they also constrain you — you must work within their patterns. Learning a framework means learning its way of doing things.

This tradeoff is usually worthwhile. Building a web application without a framework means reinventing solutions that frameworks have already perfected.

Frameworks and AI

AI coding assistants work especially well with popular frameworks because they've seen millions of examples. When you describe what you want to build, AI can generate framework-appropriate code that follows established conventions.

See More

Further Reading

You need to be signed in to leave a comment and join the discussion