DEV Community

Cover image for Library v/s Framework
Sourav Kumar
Sourav Kumar

Posted on

Library v/s Framework

Ever confused between library and frameworks ???


Do you also get confused about these two and used these two terms interchangeably.
Let me help you understand these two so you will have a better clarity.


First, lets start with definition:

Library

A collection of predefined methods, classes or interfaces used for solving common problems.
It comes either bundled with a language or can be downloaded from internet and used.

Examples - react.js, twilio, iText, apache commons and lot more.

Benefits of using library:

  1. Reusability
  2. Reduces programmer's effort
  3. Allows programmer to focus on main problem

Framework

A collection of libraries is called framework, it provides a foundation on which we develop our code.
It provides pre-written common logics so that developers can focus on business logic only also called components.

Frameworks can be further divided into following sub categories:

  • Frontend framework
  • Web framework
  • Application Development framework
  • ORM framework

Examples - angular, spring, hibernate, struts and more.

Benefits of using framework:

  1. Speeds up development process
  2. The code is more secured than library
  3. Forces developers to follow standard procedures and hence make our code clean and therefore is opinionated

Difference between library and framework

  1. Libraries are lightweight whereas frameworks are more bulky.
  2. Libraries are more flexible than frameworks.
  3. Frameworks call our code whereas we developers call library methods or functions.
  4. Frameworks employ the concept of IoC(Inversion of Control) where framework tells developers how to write the code.
  5. Frameworks controls the flow of application but we can use force library to control the flow of application.
  6. Libraries are more flexible than frameworks.

Conclusion

I hope you know the difference and advantages and disadvantages of using libraries and frameworks 🏗️.
If, you want to develop overall architecture of an application by using best practices and standards, you can use framework but if you want to develop application at a greater pace with your own custom logics and control flow on your own, you can use library 📚.


Follow me on Twitter for more.

Top comments (0)