Framework VS Library

crazysamurai

Gaurav

Posted on August 8, 2021

Framework VS Library

Let us start with the similarity between the two that is they both are reusable code written to solve a common problem and make sure the code is DRY. Assume some developer who encountered a particular problem with the program and realized that it is a very common issue and requires a lot of time and effort to resolve, so he created a library or a framework to solve the issue once and for all.

Now to the main difference between the two can be explained with the term Inversion of Control (IoC) which simply means who controls who during the development process or in simpler words it defines the relationship between the library, framework, and code.

Inversion of control

Code Controls Library

A piece of code that you require multiple times, but you must use the library to keep your code DRY. Most programming languages support libraries like React in the case of JavaScript. With a library, you can choose where to use it in your code and adjust it according to your code.

Compare this library to an actual library where you can go and pick up any book that you want and read it. In the same way, you can choose any library that suits your need and use it in your code by calling specific functions.

Framework Controls Code

A framework defines the architecture for your program and uses the code when needed. It is a collection of libraries that work together. Angular is an example of a JavaScript framework.
A framework provides most tools required to build an application and tells you where to put your code.

We can understand it by thinking of a blueprint for a building as a framework. The blueprint is how the building is planned to be constructed and the people who are going to live in it have to adjust according to it.

Basically, it controls your code which means it is in charge.

To sum it up

There may be other small differences between the two but the main difference we need to know is the inversion of control i.e. who controls who.

  • Code controls library
  • Framework controls code
💖 💪 🙅 🚩
crazysamurai
Gaurav

Posted on August 8, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Logical Operators
javascript Logical Operators

December 3, 2021

Framework VS Library
beginners Framework VS Library

August 8, 2021