Simon Willison’s Weblog


What is a development framework?

20th September 2012

My answer to What is a development framework? on Quora

The most useful distinction, in my opinion, is to think about the difference between a framework and a library.

A library is code that you can call from your project—a collection of reusable functions for manipulating PDF files, or classes for making OAuth calls, or resizing images for example. You write your code however you like, then call out to the library functions when you need them.

A framework is also reusable code, but it tends to prescribe how you use it. CodeIgniter for example strongly encourages a specific way of organising your code. In a framework, you often find yourself writing classes or functions that will be called by the framework.

Both have their strengths—libraries are great because you can mix and match them, but frameworks can solve much larger problems (like how to effectively code PHP using the MVC design pattern).

I’ve argued in the past that PHP itself is a development framework... it encourages you to organise your web code in files that map to user-facing URLs, provides a mechanism for accessing $_GET and $_POST data, and includes a huge array of web-development-specific functions baked in to the language. This is in comparison to a general purpose programming language like Ruby or Python which can’t easily be used for web development without the addition of a framework such as Django or Rails.

These are certainly not hard and fast definitions—in fact I don’t think widely agreed dictionary definitions of these terms exist. It’s how I tend to think about them though.