Library vs. Framework | The Difference!!

Muhammad Owais Raza
3 min readJan 4, 2021

The difference between libraries and frameworks can sometimes be confusing since package developers decide on their own how they should categorize their product.

Before jumping into the difference we should know what these actually are!!

What is Library?

A library provides a set of helper functions/objects/modules which your application code calls for specific functionality. Libraries typically focus on a narrow scope (e.g., strings, IO, sockets), so their API’s also tend to be smaller and require fewer dependencies. It is just a collection of class definitions. Why we need them? The reason being very simple i.e. code reuse, use the code which has already been written by other developers. Example, some library has a method named find Last Index(char) to find the last index of a particular character in a string. We can straightaway call find Last Index(char To Find) function of the library and pass the characters whose position we need to find as a parameter in the function call.

What is Framework?

Framework, on the other hand has defined open or unimplemented functions or objects which the user writes to create a custom application. (C++/Java users will understand this as it is much like implementing an abstract function). Because a framework is itself an application, it has a wider scope and includes almost everything necessary to make a user application as per his own needs.

_________________________________________________________________

Now the difference:

Inversion of Control

The primary difference between a library and a framework is the “inversion Control.” Simply put, this refers to who is in control of the programming process.

With a code library, the developer can make a call to the library whenever they want. However, with a framework, the developer is fully incorporated in its workflow. Therefore, rather than the developer is in control of the entire programming process, it is controlled by the framework.

Code Modification

Libraries come with codes that are centered toward a particular program or solve a specific program development problem. As such, they require that developers add more systems that have to be deleted as the development process progresses. However, even though frameworks generate new codes for a developer, the codes can’t be changed or modified later.

Therefore, unlike in libraries, in frameworks, you won’t have to worry about changing or deleting pre-written codes since they are non-modifiable.

___________________________________________________________________

Famous Frameworks and Libraries:

Libraries:

jQuery, Underscore and Lodash, D3.js, React, Glimmer

Frameworks:

Bootstrap, AngularJS, Ember.js, Vue.js, Aurelia

___________________________________________________________________

--

--

Muhammad Owais Raza

Frontend Developer | Beginner front-end developer and a student of Software Engineering