Library Vs Framework

Neha Ahirwar
5 min readNov 29, 2021

--

Library and Framework are both codes written by someone else that assist you to perform some common task in a less verbose way. However, many times we confuse both the terms with each other. So, let us understand what exactly library and framework are.

The major difference between a library and a framework is “Inversion of Control”. When you call a method from a library, you are in control. But with the framework, the control is inverted: the framework calls you.

So, let’s understand with the help of an example. Consider your home as a library and your university as a framework. So, at home, you don’t have many restrictions. You will enjoy the freedom to do a randomly lot of things, you can place your shoes wherever you wish, your clothes and anything. But, in university, you will adhere to certain rules. You will place the marker at the same place or somewhere near the board. So, when you have fewer rules to follow it is a library and where there are more rules it is most probably a framework.

A library is simply a collection of codes so some functions are packed together and are used over and over again.

In the library you have the power to call a code whenever you wish on the other hand frameworks calls your code and further your code can call to a library. So here you see that in the library, you are making a call to the library but in the framework, the framework is calling to your code. And further, your code can call a library.

For instance, let’s see jQuery and Django. Whenever you want to make a call to the jQuery library you can make it whereas in Django there are more restrictive environments such as template folder should always be named as templates, so can we change it yes of course but it requires digging up into the settings files, digging up into the framework. So here you will be calling your templates folder always as templates because that’s what the framework is telling you to do.

To distinguish between them, you can check, when we have more freedom it’s a library and when there are more rules it’s a framework.

Another fact is that framework can contain libraries. A framework will usually include many libraries to make your work easier.

Both libraries and Framework defines an API for programmers to use. You can consider the library as a certain function of operation and framework as the skeleton of the application and an API as a connector to put these two together. Normally, a development process begins with the framework and fills out functions defined in libraries using the API.

Which one you should use?

It is advisable to use framework over library because in the library you have to understand the functionality of each function and it is hard to create complex interactions since you need to invoke many methods to get results. Whereas the framework contains the basic flow and since one needs to plug in his behaviour it is easier to do the right thing.

Advantage of the framework over libraries

Frameworks are flexible and extensible. A framework provides you with the necessary means to extend its behaviour. One can subclass the framework classes and provide completely new functionality.

Disadvantages of Framework

The temptation to add more and more functionality creates many bloated frameworks that result in immobility and needless complexity.

Popular Frameworks

· Bootstrap-Bootstrap is a free and open-source CSS framework .It contains CSS- and JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components.

· Flask_Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions

· Django-Django is a Python-based free and open-source web framework that follows the model–template–views architectural pattern.

· Angular-Angular is a TypeScript-based free and open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations

· Ruby on Rails-Ruby on Rails, or Rails, is a server-side web application framework written in Ruby . Rail is a model–view–controller framework, providing default structures for a database, a web service, and web pages.

Popular Libraries

· jQuery-jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax

· React-React is a free and open-source front-end JavaScript library for building user interfaces based on UI components.

· PyTorch-PyTorch is an open-source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook’s AI Research lab.

· TensorFlow_TensorFlow is a free and open-source software library for machine learning and artificial intelligence. It can be used across a range of tasks but has a particular focus on training and inference of deep neural networks.

· OpenCV_OpenCV is a library of programming functions mainly aimed at real-time computer vision.

--

--