[Dev] Difference Between Library and Framework
Have you ever thought about what is the difference between library and framework? The concept is not that difficult. Both library and framework are code written by someone else that we use in our project. The difference between library and framework lies on a very simple concept “Who is controlling who?”.
What is a Library?
When we have the control of our code and use it only when we want to, we call that a library. Libraries are easy to replace, since we are in control of the code. A good example of a library would be JQuery. JQuery adds interactivity to the website. We call JQuery when we only need JQuery. This is how we use libraries. We only call it when we need it.
What is a Framework?
Different from a library, when using a framework, we don’t call the framework. The framework calls our code. You have to follow the framework’s rule. The framework tells what to do, where to put the code, and it gives a structure to follow. If you do not follow those rules, your code would not work. For example, when using DJANGO, when you want to create an admin panel, you need to write your code on the file code admin.py. If you follow the rules, you will get the desired result.
Conclusion
If you do not have to follow rules and can control your code, that is a library. However, if you have to follow rules, then it is a framework. I hope this helps clarify the difference between library and framework!