Library vs Framework - what is the difference between a library and Framework?

In this article, we are talking about the great subject of "What is the difference between a library and a Framework?" Yes, you might have already touched on that subject by looking at the definition of the library as well as in the Framework.
But those definitions are not all able to give you the whole perspective and are not able to make you understand what actually the individual subject means and also this is a common topic being asked in a variety of interviews as well the programming interviews as well. So it can be really helpful that you thoroughly understand what is the difference between a library and a framework. Trust me after reading this article you won't be searching for this topic anymore further.


Now Let me tell you what the issue is, the issue is many times people try to just say understand what is a library and then try to understand what is a framework and you'll get bored with the answers there, but it is not the perfectly correct thing. You need to understand both things side by side.

If you look out into any definitions of Wikipedia or something like that. You will find quiet a common definition which is "a collection of library is Framework" which can be true or cannot be always true. So to understand both sides by side, I will give you two examples here the II example will make much more sense but in order to understand that second example let's move on to the first example first.

Example 1

Library and Framework both of them are dependent on the rule, one is your home and the other is just like your school or university. So I am making an analogy here that your school is your framework and your home is just like your library. Here is my point when you have less number of rules it is more likely that it is going to be possibly a library and when there are more rules then there are chances that it's gonna be a Framework.

For example, in your home, you can just through off your T-shirt wherever you like and you can just place your bag whenever you like. But when you go to school or university there are fixed places where you put your bag, there are fixed places (most of the time) that you are setting up, and your marker for your teacher has a fixed place that is gonna be there.

There are some options that you can change like here or there a little bit, but it's always gonna be closer to the teacher. So that's more like you are bounded by more rules, while on the other hand at home, there is less number of rules. Yes, you may like to follow some rules but most of them are built by you.

So the library is moreover like your home. It's like whatever I want to do, I am gonna be doing it. And similarly a Framework is more bounded by the rules, that you are only allowed to do certain kinds of things yes you can go ahead and change all of them but it takes time and all such things.

Example 2

The second example is moreover code-oriented and the people who are associated with a little bit kind of code even simple JavaScript or jQuery will be able to understand it much better. Now a simple library, the library simply a collection of codes obviously, some functions or some like document object model or all such things are being packed together and being used over and over, That's basically what your library is.

Now try to understand in this manner, whenever you are making a call to any library that is most likely to be a library so whenever you have the power to call the code whenever you like, that is simply a library. On the other hand in the Framework actually, your framework calls your code and further, your code can call a library maybe.
But notice the difference here, in the library you are making a call to the library. But in the framework, Framework is actually calling to your code.


So just understand in this manner I'll take another very beautiful example which is the difference between jQuery and simply Django. In both of these things whenever you want to make a call to a jQuery library, you can make it. On the other hand in Django, there is the most restrictive environment. For example, your templates folder should always be named as a template. Can we change it??... Yes of course but it requires digging up into the settings files or digging up the framework.

It's most likely that you are gonna be calling your templates folder always templates because that's what Framework is telling you to do.


So if somebody next time asks you ....it's all about the rules. When we have more freedom that means more chances that it's gonna be a library. When there are more destructive rules then there are gonna be great chances that it can be a framework. And again who is calling to whom is a great way of getting a sense that what it is. A library or is it a Framework? If you want to get an example always in your head just remember jQuery and Django. jQuery is a library and on the other hand, your Django is a Framework.

Recent Articles

Changing Database from SQLite to MySQL - Django

One of the main benefit to use django for web development is that it comes with an inbuilt database/filesystem i.e SQLITE. Managing database and files is super easy in django. But there are some drawbacks of using SQLITE...

  - 2023-07-12
How to download a file in django

Sometimes we have to serve a file which may be a large file from our project directory. Suppose you want to transfer a file from your project directory to your friend or to some other person/server/platform....

  - 2023-07-12
How to change base url or domain in sitemap - Django

A sitemap is the first important SEO step which elaborates a website's content to search engines. It provides information to search engines about the available content on our site, which helps them to crawl webpages for indexing....

  - 2023-07-12
How to Make a Website

After reading this article you will never ever search for web development guide neither on Google nor on YouTube....

  - 2023-07-12
What is Javascript - Features and usages

I'm kind of a person who always likes to get started by installing the things & writing some code. I love that but this time JavaScript requires a little bit of the theoretical basic so that we can understand what things we are learning, how hard and powerful it is and where they can be applied....

  - 2023-07-12
Top 5 Interview Questions : Tips for HR round

In this article we are talking about the most famous HR questions and the mind-set to answer those HR questions....

  - 2023-07-12
How to get job in IT - Perfect resume guide

In today's article I want to talk about how to prepare the best resume to get a job in IT. Yes, everybody wants to have a job and in order to get a job you have to apply for it and when you apply for that, the resume is one good thing that you always submit....

  - 2023-07-12


^