Difference between a library and a framework?

Difference between a library and a framework

Howdy Reader,

Most of us always get confuse with a library and framework. So I thought of clearing the confusion with the help of this post.

Library

A library is a reusable piece of code which you use as it comes i.e it does not provide any hooks for you to extend it.

Framework

A framework is a piece of code which dictates the architecture your project will follow.

Diagram for better illustration:

difference between a library and a framework

Difference between a library and a framework

Differences (in text format): For ease of “CTRL+C” in case you need it

Library

Framework

  • A library is a reusable piece of code which you use as it comes i.e. it does not provide any hooks for you to extend it.
  • A framework is a piece of code which dictates the architecture your project will follow.
  • A library will usually focus on a single piece of functionality, which you access through an API.
  • Once you choose a framework to work with, you have to follow the framework’s code and design methodologies.
  • You call a library function, it executes some code and then control is returned to your code.
  • The framework will provide you with hooks and callbacks, so that you build on it.
  • Library doesn’t contain framework.
  • A framework will usually include a lot of libraries to make your work easier
Examples:

Examples:

  • .NET
  • CakePHP
  • Ruby on Rails

Differences (in image format): For ease of representation

Difference between a library and a framework

Difference between a library and a framework

I hope you enjoyed reading this post and are now not confused anymore between a library and a framework.

What do you think?

Dear Reader,
If you have any questions or suggestions please feel free to email us or put your thoughts as comments below. We would love to hear from you. If you found this post or article useful then please share along with your friends and help them to learn.

Happy Learning :)