DEV Community

Lucas Olivera
Lucas Olivera

Posted on • Updated on

Library vs Framework

The other day at the office a colleague approached me and asked me what I thought of Bootstrap. As I been studying Modern Web Development for the past five months he wanted to know whether he should say Bootstrap was a framework or a library. And that question caught me off guard, because I got to know I didn’t understand the differences between a library and a framework.

I am a junior developer, so what I expect from me is to research this to make a proper answer. I am very sure there are other juniors in dev.to that might not know the answer. I will try to tell you what I have learned from this.

What is a library?

  • Source: A library is a set of code that was previously written, that can be called upon when building your own code. It is work that was previously done by someone else that you can now make use of, without having to do it yourself.
  • Source: In programming, a library is a collection of precompiled routines that a program can use. The routines, sometimes called modules, are stored in object format. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.
  • To sum up: A library is a collection of codes you will be using frecuently. You may call the code directly if you need it.
  • Some well known Javascript libraries: jQuery, D3.js, React.

What is a Framework?

  • Source To understand frameworks you first need to understand libraries. Libraries are a bunch of codes that can save your time by already implementing the functionality you want. You can call the appropriate library for the appropriate job and the library does the job for you. You don’t need to know how the functions inside the libraries do their job. You just need to know how to call them. Frameworks on the other hand are just like libraries in a way that they make your job easier, but you cannot call frameworks in the same way as libraries. If you want to use framework, you have to learn the framework, because in this case, the framework call your code, and not the other way round. So you need to learn how the framework works and all the concepts inside it. In simple terms, you can call libraries, while frameworks call your code.
  • Source A library offers functions to be called by its parent code, whereas a framework defines the entire application design. A developer does not call a framework; instead it is the framework that will call and use the code in some particular way.
  • Source A software framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions. Software frameworks may include support programs, compilers, code libraries, tool sets, and application programming interfaces (APIs) that bring together all the different components to enable development of a project or system.
  • To some up: A framework defines how your application will be structured, it decides when to call code and it can include libraries, which will be used if needed.
  • Some well known Javascript frameworks: AngularJS, Backbone.js, Vue.js.

Wrapping up everything

Source:If we use the metaphor of architecture, libraries are bricks, and frameworks are, fittingly, the frame.

Library and Framework

So… What is Bootstrap then?

At the FreeCodeCamp curriculum, Bootstrap appears under the “Front End Libraries Certification” section. But in the official documentation says Bootstrap is a framework. I’m clearly not an expert, but if I had to choose I would guide me by the official documentation. Bootstrap is a CSS Framework.

What do you think?

As I already told you, I am a junior. Is this article correct? Or it has incorrect information?

Thank you for reading. Don't forget to follow me on dev.to and Twitter!

Top comments (1)

Collapse
 
fpuffer profile image
Frank Puffer

The most important difference is that frameworks (more or less) enforce a certain architecture.

By the way, this makes some people think: "Let's use that framework, hire a bunch of code monkeys and everything will be fine." Do I need to mention that I don't think this is a good strategy?