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.