In any technology project, there are numerous resources to create and achieve a functional system or application. Among them, we can name the libraries and frameworks. Next, we will tell you what they are and how they differ.
What do we call a library and what is it for?
We call a set of functions, classes and methods encoded in a programming language a library, which offers an interface or a defined contract for a specific functionality. JQuery is one of the most famous examples; it allows you to manipulate the DOM in web pages in the user’s browser. There are also, among others, PHP Mailer, which purpose is to send emails, and Guzzle, designed to make HTML requests. The latter in the PHP ecosystem.
The main purpose of a library is to execute a concrete action to reuse the code. It is an interface or a contract that defines a series of methods, which makes it easier for other applications or libraries to use the library in question.
What is a framework and when is it used?
A framework, on the other hand, brings a set of libraries and “sub-frameworks” that make the development of an application faster. Some known examples: Django in Python, Symfony in PHP and Spring in Java.
There are different types of frameworks. On the one hand, there are what we know as Configuration on Convention: those flexible ones that allow you to configure them according to your assessment. On the other hand, there are those that we identify as Convention on Configuration: they mark a series of standards that must be followed to achieve the desired result.
The choice of one or the other depends on the system that you want to carry out. If it is a project that needs speed, the second group is convenient. If, on the other hand, you are looking to develop a more robust application that is maintained over time, we recommend a framework from the first group.
You can also find frameworks that come with a full stack (you won’t need to install any other libraries to get an app) and microframeworks, those that give you the basic features and ask you to install various plugins or libraries.
How is a library different from a framework?
A library allows you to solve a specific problem, while a framework gives you a set of tools to develop systems or applications. A framework usually contains libraries (sometimes it doesn’t), provides best practices, and results in a whole development experience.