Difference between a Framework and a Library

Recently, I heard 2 of my friends talking about the difference between a framework and a library, and I thought some may need a clear explanation to see the difference. Check out the simple diagram below.



A library is essentially a set of functions that you can call, these days usually organised into classes. Each call does some work and returns control to the client. The defining characteristic of a library is that you are in control, you call the library.


A framework embodies some abstract design, with more behaviours built in. In order to use it you need to insert your behaviour into various places in the framework either by subclassing or by plugging in your own classes. The framework’s code then calls your code at these points. The defining characteristic of a framework is Inversion of Control. The framework calls you, not the other way round. (This is known as the Hollywood Principle: “Don’t call us, we’ll call you.”) The framework is in control. The flow of control and the flow of data is managed by the framework.

Hope this helps.
Good Luck,

Serdar Osman Onur
I love coding web stuff, learning/applying new technologies and techniques to create things on the internet since 2004. AboutMe G+ twitter
Serdar Osman Onur


hard work, determination, dedication, patience, consistency, faith
"We forge our bodies in the fire of our will" - Enter the Dragon - 1973 - 4 days ago
Serdar Osman Onur