Yogesh Chauhan's Blog

What’s the difference between a Framework and a Library?

in Miscellaneous on June 25, 2021

We use these terms almost everyday as developers. These are my notes regarding both with examples and differences.

A framework and a library both contain reusable functions.

You can write a library with reusable functions too that can be used by other developers. There are tons of custom CSS, JavaScript and other libraries available on GitHub. Most of them are shared by other developers as an open source project and anyone can contribute in it, others are private and can be purchased.

Library

A library is basically a set of functions that adds more functionality to your project.

When you need to perform some task, you can call one of those functions. In many cases, the functions are made for an instance of a particular class so you need to create the instance first and then call the function.

Your project is ready but you can add or remove libraries based on your need. It’s like your house or car. It’s already built but if you want to make it look nicer or add some additional “features”, you can go to some stores and get stuff to add. You don’t need to create a new car just to decorate it!

Examples: React, jQuery, Three.js, Lodash

Framework

A framework is different in that sense. It’s like a skeleton.

It’s like you have a set of features or functionalities in your mind and you need to decide from the beginning which “tool” aka framework to use to accomplish that.

Kinda like making a car or house from scratch! Yes, like making Ferrari or similar cars from scratch. Once you go with a Ferrari, you can not have some features from Tesla. For that, you need to swap the Ferrari for Tesla.

A framework has more functionalities built in. Some of those functionalities / features / functions gets fired on a specific behaviour of users or the app, other times, you need to add some kind of specific behaviour in order to fire those functions.

Examples: Angular, Vue, Django, Express

You might have got the idea regarding the technical difference. It’s about the control.

When you use a library, you have much more control over it but when you use a framework, you lose most of that control.

It’s all about what level of freedom you want as a developer.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Dec 4 What is Etrieve Flow? #Dec 2 The unique operator($) in Envision Basic #Nov 25 Steps to Install Microsoft SQL Server on a MacOS #Nov 11 What is DevOps? #Nov 10 The * arithmetic operator in Envision Basic #Nov 10 What are Big Data Clusters in SQL Server?
You might also like these
Higher Order Functions in JavaScript with ExamplesJavaScriptHow to create a circle that follows a cursor using JavaScript and CSS?CSSHow to create a for loop in SCSS (Sass)?SCSSA Quick Guide to Object-Oriented Programming in PHPPHPSanitize inputs using built-in WordPress functionsWordPressOpen Source Security Tools for Defense SecurityMiscellaneous