The Easiest Concept Between a ‘Library’ and a ‘Framework’

joylee

Joy Lee 🌻

Posted on October 21, 2020

The Easiest Concept Between a ‘Library’ and a ‘Framework’

What is the difference between a library and a framework?

If you have experienced in Software Development Industry, you may have wondered or heard this question at least once. It's also commonly asked on the programming job interview and I find many people struggling with this question. So I want to share how to answer the question in the easiest possible way.


0. Definition

What is a Library?
It's a set of code that was previously written, that can be called upon when building your own code.

What is a Framework?
It's a supporting structure where your own code defines the "meat" of the operations by filling out the structure.


1. The 1st Analogy

It is still hard to clearly understand the differences with these definition if you are a beginner. Then let's take a look at an analogy to approach them closer. You have now become a construction worker and you're assigned to build a house.

Tools (a hammer, a nail gun, etc) are your "Library"
You could build the house without any tools but if you want to make your work easier, you would use 'the set of tools'. It can be used anywhere as much as you want when needed.

The foundation of the house is your "Framework"
If there is a given foundation of the house, you must follow the regulations. Otherwise, the house cannot be built in proper way. The foundation dictates how your project will be structured.


2. The 2nd Analogy

Here is another analogy that would help you to understand more clearly.

Your home is your "Library"
There are a less number of rules. You can just throw your T-shirt and place your bag anywhere. You may have to follow some rules but most of them are built by you. You can do it whatever you feel like.

Your school is your "Framework"
There are a large number of rules . You have your own uniform and your seat is fixed that you cannot place your stuff randomly. You are only allowed to do certain things.


3. The Relation

Now you have an idea of what a library and a framework is. However, there is one more significant difference between two terms. It's called 'Inversion of Control'

Image description

Who is controlling whom?
Our code flows a little bit different on a library and a framework. When we use a library, we are in charge of the flow of the application. We are the ones choosing when and where to call the library. On the other hand, when we use a framework, the framework is in charge of the flow. The framework itself is making calls toward our code.


4. Examples

Last but not least, let's check out the major libraries and frameworks below.

Popular Libraries
jQuery, Lodash, React, Redux

Popular Frameworks
Rails, Angular, Django, Express


5. Conclusion

Finally, we are able to describe the difference in one sentence.

Q : What is the difference between a library and a framework?
A : You call a library as it's a simple tool whereas a framework calls you as it's a restrictive foundation.


Reference ::: Nomad Coder. Difference between Library and Framework. Youtube Jun 17, 2020_ Codecademy. What are Libraries and Frameworks?. Youtube. Jun 5, 2019. __ Hitesh Choudhary. What is the difference between a Library and a Framework. Youtube. Mar 13, 2018!_

💖 💪 🙅 🚩
joylee
Joy Lee 🌻

Posted on October 21, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related