Differences between a framework and a library.

Differences between a framework and a library.

We developers tend to use these two terms interchangeably. What we don’t know is that there are prime differences between the two. In this article, the distinctions between the two will be discussed.

What is a framework?

Predominantly, a framework refers to a structure, plan, or system. It could be a structure for anything.

We developers do not always need to start from scratch when building applications; we have tools like frameworks to assist us. A framework is an abstraction in which software, providing generic functionality, can be selectively changed by additional user-written code, thus providing application-specific software.

Nature of frameworks

Frameworks have a few characteristics that distinguish them from libraries:

  1. Inversion of control is a design principle that allows classes to be loosely coupled and, therefore, easier to test and maintain. In a framework, the overall flow is not dictated by the user but by the framework.
  2. A user can extend the framework.
  3. You can extend a framework but not modify its code.

Examples of frameworks

  • Laravel (uses PHP)
  • Django (uses Python)
  • Ruby on Rails (uses Ruby)
  • ASP. net (uses C#)
  • Express (uses Javascript)
  • Spring (uses Java)
  • Angular (uses Javascript)
  • Ember (uses Javascript)
  • Vue (uses Javascript)

What is a library?

A library is a collection of books. In software engineering, a library is simply a collection of prewritten code used to simplify tasks. This collection of reusable code is usually targeted for specific common problems. A library usually includes a few different pre-coded components.

Examples of a library

  • NumPy (uses Python)
  • Matplotlib (uses Python)
  • SMFL (uses C++)
  • p5 (uses Javascript)
  • jQuery (uses Javascript)
  • React.js (uses Javascript)

What is the difference between a framework and a library?

Whenever asked this question, I like to explain it with this analogy: A framework is buying an already-built house, and a library is building a house from scratch. The house is constructed already, therefore, you never have to worry about building problems, but you cannot choose how the rooms are arranged.

Other differences include

table.png

I hope this helps you. Please share this to educate others. Feel free to ask questions, I’m here to help.