Framework or Library: Which is Better?

Kavita Verma
SiteSonic
Published in
5 min readJul 5, 2019

There are distinct ways by which you can design a website, Library, and Framework being the prominent ones. Those having a Computer Science background might be familiar with the terms, framework, and library.

Basically, the framework illustrates how your project is going to be structured, whereas the library is a building block of an application that can be used independently. Some developers prefer framework while others use libraries. Few can go out of the box and use a combination of both.

The differentiating feature is the “Inversion of Control.” In the left figure, the application is controlled by a framework, whereas in latter, an application handles all the libraries according to need. The following post contains all the necessary information you need to know about either of them. Stay in the know!

What is a Framework?

A framework is a reusable design which compiles in a specific flow and executes the additional code you have written with it. It has its priority list and order to operate with. The framework demonstrates the concept, but an interface defines the functionality that is useful for end-users.

Some areas where the framework is prominent are web application systems, Plug-in manager, GUI systems.

It can also house many libraries and even other programming languages.

The control flow is already present in the framework along with various white spots, when we can enter according to our coding requirement. It is usually more complex stuff and with a good reason. It has its predefined structures where an application defines its features to fit in those structures.

This way, the code will be called by the framework at the right time.

“You do not have to worry about your design if the main motive of your website is implementing basic domain-specific functions,” says Akram Artoul, the CEO of SonicSite. It offers hooks and call-backs so that you use it; it will then call plugged-in code wherever and whenever it needs.

This is the called Inversion of Control commonly called as IoC.

What is a Library?

The library is defined as an inventory of class definitions. Why we use it? The apparent reason is that they are simple to understand and have a smooth working principle that is using the codes already written by other developers.

Front-end libraries are created internally using JavaScript to facilitate the process of hardcore coding into simple one-liners. To ease the process of manipulating and changing the Document Object Model (DOM), we use libraries.

For instance, some libraries have a method names findLastIndex(char) to discover the last index of a specific character in a string and pass its position to find as a parameter in the function call.

Libraries can have a dependency on other libraries but not on other programming languages.

Common areas where Library is significant are network protocols, compression, image manipulation, string utilities, regular expression evaluation, math formulas, etc.

Akram Artoul, CEO of SonicSite, says that unlike framework, libraries don’t take charge. You get to decide how the flow of your code should be. You can call any API of a library anytime you want according to your requirement. It will execute some code, and then again, control gets restored to you.

The Difference: Vue.js vs. jQuery

Vue.js is a TYPESCRIPT that provides a platform to create responsive single page applications. It combines various declarative templates, dependency relations, end-to-end tools, and integrates peculiar practices to solve development problems.

Whereas, jQuery is a fast and featured JavaScript Library that is nothing but “code reuse.” It can be used with almost all web browsers including Chrome, Safari, Firefox, and so on to manipulate events, elements, AJAX requests, effects, etc.

Let us understand the difference between a framework and a library, more technically, using jQuery (library) and Vue.js (framework).

Take a scenario of updating the content of an element in your website. Below given images will illustrate how jQuery and Vue.jsperform the same function but in a totally different way. Have a look!

jQuery

Pay attention to how we use jQuery. Now you can call your program where you want it.

jQuery requires a certain set of input values. So, when you call that function, it automatically finds the definition in a function library, and then executes the particular block of code. You are still in-charge.

Vue.js

Looking at the code written in Vue.js, you can see that there are blank spaces in the code to be filled, called constructor. This constructor is an object with various features. It can tell you what the code needs and then, at the back, decides the time when will you require it. Vue is in-charge in this case.

The only fundamental difference between these two styles of coding is that whether or not there is an ‘Inversion of Contro.’

Is it Good to Use Both?

Now thoughts on using a framework and a library, simultaneously, can be fascinating. Some might have built anxious thoughts on whether or not they both can be implemented together. Who knows?

Akram Artoul, CEO of SiteSonic states, “most of the frameworks come furled with libraries to ease the method of making websites and implement feature.” Thereby, the framework and library are actually being used simultaneously.

In contrast, libraries are usually designed to be used as a stand-alone feature. This is fine as long as you are already using your “main” library. But including just one big library for the sake of one characteristic is a bad practice. Always keep in mind the size of the entire package before inserting libraries.

Wrapping Up

There is a possibility that after reading the post, many of you might think that one is better than the other.

Well, don’t make that kind of concept in mind because it solely depends on the situation whether a library can be beneficial or a framework. Both have their pros and cons regarding the same.

Therefore, it’s your choice to select any of the tools to make your website free from any development bug, performance hick-up, or any design issue.

--

--

Kavita Verma
SiteSonic

Kavita's world revolves around highly technical sphere! She loves to keep a tab on what's happening in the world of technology.