The Difference Between a Framework and a Library

Robert M Ricci
The Startup
Published in
3 min readDec 13, 2020

In my quest in trying to become an all-around better programmer, I’ve decided to research ideas, that I’m not entirely sure about. So for this post, I’ve done some research on the differences between a library and a framework. They are two terms that are passed around almost interchangeable, but they do have some slight differences.

First, let's get a basic definition of both a library and a framework. A library is a collection of precompiled routines that a program can use. Meanwhile, 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. Wow, those sound fairly similar, sure the framework definition is longer, but they seem to do the same thing. They are basically a collection of pre-written code that can be used to help you write a program. Almost as a direct comparison to the definition listed above the difference between the two are the same. A framework is usually just larger in scope than a library. A framework does just a little more than a library.

Now, let discuss some of those differences. The one I consider to be the main difference is what is known as inversion of control. What that basically boils down to is, who is in control of the flow of the program. In a library you the user are in charge of the flow, calling the library when you want to use it. In contrast, a framework is in control of the flow, telling you where to plug in your code.

When researching this topic you get a lot of analogies trying to explain the differences, so let me add one. As I come from a bartending background let’s use a cocktail. A library is like wanting a cocktail, you can’t make spirits ( or rather you shouldn’t) at home, so you buy them, but you ultimately decide how the ingredients get mixed together. A framework, on the other hand, is like just going to a bar and ordering a cocktail. You still get to decide what’s in the cocktail, but not the preparation method, and now I want a cocktail.

Just a note you will often hear the phrase “opinionated or non-opinionated” tossed around when discussing the difference between libraries and frameworks. The basic discussion is that frameworks, are “opinionated”, as you have to follow the path that they set out for you. From what I read there is some debate about this phrasing, as some frameworks can be considered “opinionated” than others.

I think I have a good grasp of the differences between the two now. I hope this helped you as well. I wonder what I should research next. So many topics so little time.

RESOURCES:

https://www.freecodecamp.org/news/the-difference-between-a-framework-and-a-library-bd133054023f/#:~:text=The%20technical%20difference%20between%20a,in%20charge%20of%20the%20flow.

https://en.wikipedia.org/wiki/Software_framework#:~:text=In%20computer%20programming%2C%20a%20software,thus%20providing%20application%2Dspecific%20software.

https://en.wikipedia.org/wiki/Library_(computing)

--

--

Robert M Ricci
The Startup

Full Stack Developer Ruby and Javascript. Recent grad of the Flatiron School.