DEV Community

Discussion on: Please ELI5: Frameworks vs Libraries vs API

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

Framework

A framework uses the Hollywood Principle - "Don't call us, we'll call you." You have to integrate your code into a framework. Your code has to conform to the framework structure. Usually meaning it has to implement specific methods or properties.

Advantages

  • It provides an opinionated mix of technology to accomplish some common scenarios for you.
    • Can allow you to develop an app quickly.

Disadvantages

  • It may not cover your specific needs, and you may have to work around the framework to accomplish them.
  • It often does extra things you do not need but still have to deal with.
  • Significant framework updates can be very expensive for you.
    • Because your app is coupled to the framework in so many places.
    • Often apps will choose to stay at an old framework version instead of upgrading.
  • Cannot switch frameworks -- it typically means rewriting the application.

Library

A library performs a specific function, and you call it for that function, and then move on with the rest of your code. When building your app from libraries...

Advantages

  • You retain control over the structure of your application, making it more adaptable to new situations.
  • It is relatively easy to add new functionality by integrating new libraries.
  • Significant updates to a library tend to affect only small portions of a code base.
    • You can usually accomplish major upgrades of a library.
  • Can change libraries if a better alternative arises.

Disadvantage

  • You are responsible for developing the structure of the app.
    • This takes time and iteration.
    • Whereas a framework would decide this up front for you.

API

API is an overloaded term. Generally speaking, it just refers to any library or framework's surface area... the exposed objects, methods, etc. that you are supposed to use. It is the dev equivalent of a user interface.

Web API

More specifically, a "web API" is typically a service that runs on the back-end to perform functions that the (usually Javascript) front-end is not capable of doing directly. So the front-end makes HTTP calls to the API service, which performs the functionality on the server. Examples: saving to database, sending email. Some web APIs are public, meaning anyone can call them to get data.

Collapse
 
sup profile image
Supratim

Thank you!!It was very helpful :)