Tuesday, June 2, 2020

What is the difference between a library and a framework? | Library vs Framework

Everyone in the programming world must have heard of these terms at least once. In fact, This is one of the most popular questions asked in the Interview, and In this article, we are going to discuss these terms in detail, and I'll try to make it as easy as possible for you to understand.

If you search google about what is Library and Framework, you will get the same definition every time that collection of Library is called a framework which can be or which cannot be accurate. So you have to understand both of them side by side.

Explaining the Library and the Framework

So first of all, before starting to explain with the help of examples, let me tell you that both Framework and Library depend on rules.
Now Let's try to understand them with the help of an example. Consider the Framework as your school and Library as your home. So here is my point that when there are fewer rules, then there are chances that it is possibly a library, and when there are more rules, then there are chances that it is likely a Framework. Similarly, like when you are home, you have to obey fewer rules like you can sit wherever or you can put your bag where ever you want, i.e., you can make your rules yourself, which may not be the case when you are in a school. You are likely to follow more rules there, i.e., you are bounded to rules that are already set by the teachers.

Now let's move on to the second example, which is somewhat more code-oriented, and the people who are more associated with the programming languages like javascript or jquery will understand this more easily.
So In a Library, there are collections of codes(consisting of functions, DOMs, etc.) that are used repeatedly throughout the program. In simple words, when you have the power to call the code whenever and where ever you like that is your Library. On the other hand, in the Framework, actually, your Framework calls the code, and then further, you can call your Library sometimes maybe.

The main difference between the Library and Framework is, in Library, you are making a call to your code whereas, in Framework, it is the one who is calling your code.

I will use the most famous names from the coding world, JQuery, and Django, to explain what we have learned so far.
In JQuery, you can call any library in your code where ever you like, and there are no restrictions. In contrast, in Django, there are more set of rules which need to be followed like it is mandatory to name template folder as the template, yes we can change it, but we have to dig deep down into the settings. So The conclusion that comes out here is, JQuery, which has fewer rules, is a Library whereas Django, with more restrictions and regulations, is a Framework.


In this article, I tried to explain the difference between Library and Framework with the help of simple examples. Now you can quickly answer the questions related to this or tell this difference to anyone much quickly. If you liked the article consider sharing or bookmarking.

If you have any doubts, consider commenting. I'll be more than happy to answer the queries in the comment section
Previous Post
Next Post

post written by:

Hi, Navjyot Singh is a coder, content maker and a freelance developer who's pursuing an undergraduate Engineering degree in Computer Science. He started out as a web developer but later picked up the mobile as his favourite platform to develop applications. A Writer by day and coder by night is loathed to discuss himself as the third person but can be persuaded to do so from time to time.