Library vs Framework vs API

What are libraries, frameworks, and APIs? These terms get thrown around a lot and sometimes even used interchangably to describe the same thing.

So let me begin by saying that libraries, frameworks, and APIs are all different things. They may be used…


This content originally appeared on DEV Community and was authored by William Olsen

What are libraries, frameworks, and APIs? These terms get thrown around a lot and sometimes even used interchangably to describe the same thing.

So let me begin by saying that libraries, frameworks, and APIs are all different things. They may be used to accomplish the same task, but are all fundamentally different. "What are those differences?" I hear you ask. Let me explain each one:

Library

Basically, a library is just a bunch of methods/fields that can be reused to easily accomplish a task, or more usually a domain of tasks.

Pros:

  • More developer freedom
  • Usually easier to use
  • Able to add/remove/replace on-the-fly

Cons:

  • Developer is responsible for the structure
  • Longer road to finished product
  • Bigger possibility for human error

As I have annoyingly promoted throughout my blog posts thus far, I am developing my library Impart. The reason Impart is not a framework is because of the tool access. You can render a WebPage or start a Website anytime. There is no template for how the code is meant to be written, it provides the tools and gives you the freedom to use them.

Framework

Think of a framework as a more controlling library. A framework will handle the general flow of an application with no say from the developer.

Pros:

  • Framework is responsible for the structure
  • Shorter road to finished product
  • Less possibility for human error

Cons:

  • Less developer freedom
  • Usually more complex than libraries
  • Integration is more difficult

A great example of a framework is the .NET framework. Well... I should say .NET, as .NET Core (now called .NET) replaced it as the Microsoft framework solution with an open source license and better cross-platform capabilities. Microsoft makes things way too complicated, especially with their branding of "open source developer platform" and naming their main CLI "dotnet". Tangeant aside, just know by .NET I mean the cross-platform framework that is specifically a framework because it controls the flow of an application. By "it controls" I really mean the individual frameworks underneath it because .NET is just a bunch of frameworks for doing specific tasks. (possible blog post about what is included in .NET upcoming?)

API

This term is misused a lot. I don't think I have ever heard a code-related term be used incorrectly as much as API has. In short, an API (Application Programming Interface) is really just the exposed (public) part of an internal library/framework.

Pros:

  • Better user security
  • Simpler than hardware-level interactions
  • Less possibility for human error

Cons:

  • Less developer freedom
  • Parameter passing can be a pain
  • Integration is more difficult across systems

Going back to Microsoft, I love Windows' API: Win32. This API allows for system commands that Windows just doesn't trust the developer to do on their own. This can include things like editing the clipboard to having a password dialogue pop up. Given, parameter passing into the external methods can get annoying with the different types and having to create custom structs for certain tasks. But I do understand why Win32 exists. It adds a layer of security and standarization to an otherwise unsecure and non-regulated way of completing system-level tasks.

Web API

This is a type of API meant for sending, receiving, and processing information via web requests. This section will not have a pro/con portion considering that they are literally essential to web communication. I will instead elaborate on the common ways of implementing a web API.

REST (Representational State Transfer):

  • Standardization of incoming requests
  • More flexible
  • Generally uses JSON formatting
  • Stateless
  • Uses HTTP(S)
  • Responses can contain executable code

SOAP (Simple Object Access Protocol):

  • Generally less code required
  • More strict
  • Only uses XML formatting
  • Can use HTTP(S), SMTP, and TCP

My apologies for a longer wait for this post, I have been busy lately and this required a fair amount of research to compile together all of this information. It is very possible I made a mistake, so feel free to correct any misinformation in the comments.

Adapted from this amazing comment.

Thanks for reading!

(Cover image source)


This content originally appeared on DEV Community and was authored by William Olsen


Print Share Comment Cite Upload Translate Updates
APA

William Olsen | Sciencx (2022-05-12T04:16:30+00:00) Library vs Framework vs API. Retrieved from https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/

MLA
" » Library vs Framework vs API." William Olsen | Sciencx - Thursday May 12, 2022, https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/
HARVARD
William Olsen | Sciencx Thursday May 12, 2022 » Library vs Framework vs API., viewed ,<https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/>
VANCOUVER
William Olsen | Sciencx - » Library vs Framework vs API. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/
CHICAGO
" » Library vs Framework vs API." William Olsen | Sciencx - Accessed . https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/
IEEE
" » Library vs Framework vs API." William Olsen | Sciencx [Online]. Available: https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/. [Accessed: ]
rf:citation
» Library vs Framework vs API | William Olsen | Sciencx | https://www.scien.cx/2022/05/12/library-vs-framework-vs-api/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.