What the hell is the difference between an API, Library and Framework?!?!?!?!

November 20, 2016

During my mock interview I was asked to explain what an API was, which I could only reply that jQuery and Bootstrap were such examples. I felt like I should have known what the definition was or at least explain it in an analogy, but I really never thought about it. I just knew it was something that aided me in creating an application. Immediately afterwards I looked up the definition, but it still felt vague. Things began to feel more vague as libraries and frameworks were thrown into the examples, which made me realize that I couldn’t distinguish the difference between any of these concepts. After googling left and right I feel like I have a much better understanding of everything, which I want to pass to you in gift wrapped present with with a big bow on top.

First of all API stands for Application Program Interface, which can be thought of as a piece of software that a user has access to through an agreement or contract. If the user can access the API, the API agrees to perform some task in return. An API can be made up of many libraries to get such as task done but a library by itself is just a collection of useful methods or functions. Just like an API can be a library so can a framework. A framework such as Angular or Flask gives a user the foundation for making applications much more efficiently because someone else, probably much smarter, already spent the time building the infrastructure. The user now just needs to read and understand the instruction manual.

To put all of these concepts together, I like the restaurant analogy. A customer(user) can browse a menu of food(API references) and call upon the waiter to order a dish. The customer doesn’t care about the details of how it gets made and the chef won’t tell you anyway because its his secret recipe. The customer does however want to be able to pass arguments so their steak can be ordered extra bloody just how they like it.

Not quite in the same analogy but still using the restaurant example, if the user(programmer) is now the chef cooking for his customers he has the option of making everything from scratch with just some firewood and his hands or he could have some ready done ingredients such as the bread or pasta(libraries) and use a stove/oven(frameworks) to get the job done faster….and with tastier results.