A framework is an arrangement which software provides a greater functionality that can be extended by additional user written codes. Which simply means, a framework is a basic structure which you add your code to have a greater functionality of that system. It allows to create a standard way of creating applications. And the functions in a framework are reusable.
A framework and library are not the same
- A library is a reusable piece of code which you use as it comes. It does not provide any ability to extend it. But a framework is a piece of code which dictates the architecture your project will follow.
- A library usually focus on a single piece of functionality, which you access through an API. But once you choose a framework to work with, you have to follow the framework’s code and design methodologies.
- When you call a library function, it executes some code and then control is returned to your code. But framework will provide you with basics and callbacks , so that you can built on it.
- Library is not a framework. But a framework contains libraries.
- Examples for libraries are : jQuery , Prototype , jsPHP
- Examples for frameworks are : .NET , CakePHP , Ruby On Rails

Advantages of frameworks
- It’s open source.
- It provides good documentation and support.
- Efficient.
- Secure.
- Easy to integrate.
