What is the difference between Library and Framework?

What is the difference between Library and Framework?

Hello guys, hope you all are well. If you are confused between the terms Library and Framework, then you are at right place to clear your confusion. So without wasting further, let's start our another journey of learning through this article.

image.png

Let's start with an example-1, suppose you bought an empty land and you want to build a house. You have your own design, resources and you can create a house whatever you like. Basically you are master of your own and you don't have to follow anyone instructions or procedures or protocols or standard format.

Now coming with example-2, suppose you want to build a model home. You have a set of blueprints and a few limited choices when it comes to architecture and design. The contractor and blueprint will let you know when and where you can provide your input. You are not master of your own in terms of architecture and design and have to follow other's instructions, procedures, protocols and standard format.

I hope you understand the above two examples, now let's clear the difference between the terms Library and Framework, so example-1 tells about the Library and example-2 about Framework.

So, What is Library?

  • provides a set of helper functions/objects/modules
  • just use the functions/modules present in library and build your home whatever you want to
  • flow of control is in our hands

and Framework?

  • gives us a basic structure around which we can add our code
  • known to be a skeleton where the application defines the content of the operation by filling out the skeleton
  • forces us to work in a specific standard manner
  • flow of control is in hands of framework

What a framework can do?

A framework simplifies the process of creating web applications. So how it does that, suppose a user is creating a web application from the scratch, so what he will do? He will create some empty directories. Inside which he will create some basic files such as "index.html", style.css, and every time he starts a new project, he has to start from scratch and he has to repeat the exact same process for every new project.

Here the framework play's its significant role and it will do this work for the users and the user just has to start from his logic, the user does not have to start from the scratch every time he creates a new project. Now user just has to focus on the big picture of the project and framework saves a lot of time for us.

Why need Library?

To reuse the code that has been already written by someone else (or other developers) which helps the developer to avoid writing code for some functionality for which code is already written in the library

and why need Framework?

The functions defined in the framework are reusable which means if we want to use the same functionality in the several different places inside the project we can use that and we also don't need to create that function because framework has done lots of work for us.

Basically the purpose of Framework and Library is same, that is Reusability.

Key Differences between Library and Framework

  • Framework is software but Library is not
  • Framework provides standard way of developing applications while Library does not
  • Framework controls the flow while in Library, we controls the flow
  • User has freedom in Library while not in Framework

image.png

If you have read this article, one question is there for you, can you tell if React is Library or Framework?? Please do comment your answers, if you really learned from this article.

image.png

Did you find this article valuable?

Support Anubhav Goyal by becoming a sponsor. Any amount is appreciated!