Difference Between Similar Terms and Objects

Difference Between Library and Framework

Choosing the right tool or technology for a given problem is one of the most important aspects of programming. The right tool is the key to a project’s success. This is where most programmers fail because they usually deal with many tools. This pertains to the ultimate question, “should you build your application with a library or a framework?” This is one of the most debatable topics of discussion within the programmers’ community and often a source of confusion. A small team with a handful of developers, mostly beginners may be better off working with a framework whereas libraries are building blocks that can be used anywhere and allow for greater flexibility and control.

The key difference between a library and a framework is the “Inversion of Control” (IoC). One could say framework is a collection of libraries but the whole idea is somehow different.

 

What is Library?

Library is a collection of reusable functions used by computer programs meaning the resources which you can reuse which may include classes, subroutines, pre-compiled code, message templates, etc. Mostly programming languages have their own standard libraries but programmers can also create their own custom libraries. It simply is a piece of code written by other developers that can be reused anywhere. Libraries can be seamlessly incorporated into existing projects to add functionality which you can further access using an API. A little knowledge is required you to get started.

What is Framework?

Framework is a piece of code that dictates how the project should be structured and run. It simply mandates the architecture of your project like defining the design parameters of an application so that you can focus on the specifics of the project, thereby emphasizing on reusability of design rather than reusability of code. Unlike libraries, the control is inverted in case of frameworks and the code never calls into a framework, instead, the framework calls you. Unlike libraries, frameworks emphasize on structure and standards.

 

Difference between Library and Framework

  1. Meaning

In programming, library is a collection of reusable functions – meaning the resources you can reuse – used by computer programs. The resources, sometimes called as modules, are generally stored in object format. Most programming languages have their own standard libraries but programmers can also create their own custom libraries. In simple terms, a library is a set of functions that you can call, whereas a framework is a piece of code that dictates the architecture of your project. In a way, frameworks and programming languages are intertwined that together aid in computer programs.

  1. Inversion of Control

The “Inversion of Control” is the key difference which separates a framework from a library. A library is a set of functions and routines used by other programs and you are in full control if it when you call a method from a library. However, the control is inverted in case of a framework. It dictates the structure of your project and the code never calls into a framework, instead, it calls you. Simply put, you can simply think of library as a function of an application and a framework as the skeleton of the application in which the application defines its own features.

  1. Function

Libraries are a set of functions that can be used anywhere meaning it simply is a piece of code written by other developers which can be reused. They are incorporated seamlessly into existing projects to add functionality that you can access using an API. They are mostly used for frequently used modules because you don’t have to explicitly link them to every program that uses them. They are important in program linking and binding process. Frameworks, on the other hand, provide a standard way to build and deploy applications and can be mostly used when starting a new project rather than integrated into existing ones.

  1. Example

To better understand the difference between a library and a framework, let’s take a look at jQuery and AngularJS. jQuery is a cross-platform JavaScript library that simplifies DOM manipulation along with a lot of other complicated things such as CSS manipulation, HTML event methods, AJAX calls etc. The purpose of jQuery is to simplify use of JavaScript on your website. AngularJS, on the other hand, is a structural framework based on the MVC architecture used for creating dynamic web applications. It’s entirely based on HTML and JavaScript and unlike jQuery, it cannot be integrated into existing projects because as a framework, it dictates how your code is to be structured and run.

Library vs. Framework: Comparison Chart

 

Summary of Library vs. Framework

When there’s confusion about deciding whether you should be using a library or a framework for building an application, it all comes down to control. Libraries are a set of functions that you can call and each call performs some task and returns back the control to you. They can be seamlessly incorporated into existing projects and a little knowledge is required to get you started. Frameworks, on the other hand, dictate the overall structure of your project and unlike libraries, frameworks call you and the code never calls into a framework. The key difference is of course the Inversion of Control. In simple terms, libraries are more flexible with greater degree of control, whereas frameworks enforce structure and standards.

Latest posts by Sagar Khillar (see all)

Sharing is caring!


Search DifferenceBetween.net :




Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.


1 Comment

  1. Hi,

    This is a nice site from learning point of view. i have marked in my bookmark list and found it really helpful.
    I thought let’s tribute to the people sitting behind this site. so i really appreciate your work and dedication to this site. Keep sharing and keep letting us learn. Thank you

    Regards,
    Muhammad Saeed Talib
    Software Engineer

Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

References :


[0]Monteiro, Fernando. AngularJS Directives Cookbook. Birmingham: Packt Publishing, 2015. Print

[1]Wilson, Leslie B., and Robert G. Clark. Comparative Programming Languages. England: Addison-Wesley. 1988. Print

[2]Wexelblat, Richard L. History of Programming Languages. NY: Academic Press, 2014. Print

[3]Image credit: https://upload.wikimedia.org/wikipedia/commons/0/02/Application_Framework.png

[4]Image credit: https://upload.wikimedia.org/wikipedia/commons/c/cb/Conventional_Software_Library.png

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.


See more about : ,
Protected by Copyscape Plagiarism Finder