Libraries and Frameworks

Ashutosh Paul
3 min readJun 7, 2020

--

It’s confusing when you hear someone say:

Hey! I have built my project with the help of this library.

And,

Hey! I have built my project with the help of this framework.

From the name itself we get an idea that library and framework are two different things with completely different meaning.

Let’s understand the difference between a library and a framework.

Before diving into the technical difference, first, lets get a clear idea about these two terms.

Let’s say you ordered a veg-pizza from Domino’s and your friend ordered another veg-pizza from Pizza Hut. As you will notice both the pizza’s are made up of same ingredients. But, they taste different.

Pizza

One pizza tastes different from the other because of some reasons. The instrument in which they were cooked or baked might be different. Or the process by which the pizzas were made might be different from one another. Hence resulting in different taste.

Similarly, a library contains ingredients (classes and methods) which can be used as per requirement. Just like in the case of pizza. Domino’s and Pizza Hut had used same same ingredients like corn, tomato, mushroom etc.

A programmer uses different libraries as per the need of the program. Programmer may use one or multiple libraries.

Different applications need different method and platform for development.

For developing a web-app, a developer may choose between React or Angular. A JAVA developer may choose among Spring, Grails or something else.

A framework is a skeleton of a project. Different frameworks use different method for app creation. Hence giving the app a different shape. We can say in the case of pizzas, Domino’s and Pizza Hut were two different frameworks.

Now, we have a basic idea of libraries and frameworks. Lets continue discussing the technical differences.

The key difference between a library and a framework is “Inversion of Control”. When you call a method from a library, you are in control. But with a framework, the control is inverted: the framework calls you.

A library is just a collection of class definitions. The reason behind is simply code reuse, i.e. get the code that has already been written by other developers. The classes and methods normally define specific operations in a domain specific area. For example, there are some libraries of mathematics which can let developer just call the function without redo the implementation of how an algorithm works.

JavaScript Frameworks

In framework, all the control flow is already there, and there’s a bunch of predefined white spots that you should fill out with your code. A framework is normally more complex. It defines a skeleton where the application defines its own features to fill out the skeleton. In this way, your code will be called by the framework when appropriately. The benefit is that developers do not need to worry about if a design is good or not, but just about implementing domain specific functions.

The source of technical difference (above three paragraphs) between library and framework is here.

Have a great day ahead😊.

Thank you.

--

--