DEV Community

Shariq Ahmed
Shariq Ahmed

Posted on • Updated on

Framework vs Library: Understanding the difference with an example

Framework vs Library: Understanding the Difference

Before we delve into their differences, keep in mind that both frameworks and libraries are codes written by someone else.

Framework

In a framework, the flow in which a particular class or function is written is predefined and can’t be disrupted or modified by the developer. The developer cannot call any class or function with his or her choice.

In other words, the control is not in the developer’s hands. Instead, the framework controls the call of libraries. With the use of a framework, one can quickly create, and deploy a software application. Additionally, it’s equipped with easy tools, templates, etc. that contribute to the fast development of applications.

Using the framework, we can also create advanced user experiences. But the con of using a framework is that at times, the development of websites becomes somewhat complex. Also, the right framework should be chosen for a website. Else, both website performance and user experience will worsen.

Library

Contrarily, in a library, developers can disrupt the flow, allowing them to call any class or function at any point in the code.

In other words, the control is in the hands of the developer. Libraries are particularly useful when you want to add specific functions to a website. With the use of libraries, the cost of website development is also cut down.

At times, libraries also come with pre-tested codes for different environments. But there are also times when application performance is affected, because of the use of several libraries. And what’s worse is that libraries are also prone to attacks. Also, in an environment where libraries aren’t supported, if we still use libraries then we need to use wrapper. This ultimately affects app performance.

Conclusion

Now, if you still don’t understand the difference between framework and library, then here’s an example for you.

Imagine you want to build a big house. One way to fulfill this wish is to buy a prebuilt big house and modify it according to your preferences. This is an example of a framework. Another way is to buy a piece of land and construct your house exactly the way you want it. And this is exactly what happens when we use the library.

Top comments (0)