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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Short-Circuit Evaluation in JavaScriptJavaScriptLearn to make a responsive gallery using CSS Grid and without media queriesCSSUPDATE and DELETE Statements in PostgresPostgresLearn to Implement Estimated Reading Time using PHP Part 1: The BasicsPHPWhat is Zdog?Miscellaneoustransform-origin Property in CSSCSS