Library vs Framework

Alihaider
3 min readJan 5, 2021

Developers often use the terms “library” and “framework” interchangeably. But there is a difference.

What Is The Difference Between Library And Framework

this is the question which many people ask in the programming world:

What is Library?

A library refers to a set of non-volatile resources such as helper functions/modules/objects used by developers to complete specific functionalities. They include things like configuration data, pre-written code, message templates, and documentation, among others. Libraries are designed to assist programmers in building cutting-edge software by simplifying some part of the coding process. They tend to focus on a specific area of application development or solve a particular programming problem

A library is like going to Ikea. You already have a home, but you need a bit of help with furniture. You don’t feel like making your own table from scratch. Ikea allows you to pick and choose different things to go in your home. You are in control.

Let’s take the analogy of baking a cake to help you understand what a library is:

If you are looking to bake a cake for your upcoming birthday, you need to have all the ingredients ready. However, since you don’t grow things such as strawberries at home, you must get them from the stores (library). And during the whole process of baking (programming), you will have total control until you have your fully cooked cake (program).

For example, if you want to find the last index of a character string, you don’t need to build code from scratch to help you do this. You can find a library with a method named find last index(char) and make the call straight away and get the characters whose position you need to see as a parameter in the function call.

What is Framework?

A framework is an abstraction that boasts pre-defined or unimplemented functions/objects that help developers create custom applications. It provides you with a standard means of creating and deploying applications in a universal and pre-defined software environment by offering particular functionalities as part of a bigger software platform. Unlike libraries, which are designed to solve specific problems or add a particular feature to a program, frameworks offer something more generic and reusable. A framework can encompass everything you use in application development.

In short, a framework is a skeleton that boasts pre-written codes that help developers build top-tier applications. Some examples include the Plug-in manager, web application system, and GUI system, among many others.

Let’s go back to the same analogy of baking a cake:

When it comes to a framework, you get your cake by purchasing it from a bakery. And although you’ll not be involved in the baking, you can still decide some of the things you want, such as color, design, and flavor. However, unlike in the situation where you baked the cake yourself (library), and had total control of the entire baking process (program development process), in this case, this situation will be controlled by the bakery (framework)

In summary

  • Frameworks and libraries are both code written by someone else that helps you perform some common tasks in a less verbose way.
  • A framework inverts the control of the program. It tells the developer what they need. A library doesn’t. The programmer calls the library where and when they need it.
  • The degree of freedom a library or framework gives the developer will dictate how “opinionated” it is.

And In the last here are some popular libraries and frameworks:

Popular Libraries: Rails, Angular, Django, Express

Popular Frameworks: React, jQuery, Lodash, Redux

Thanks for reading!

--

--