Software framework vs library

@Anil's Notes
3 min readOct 13, 2021

Isn’t this one of the most common questions asked in interviews? Throughout my career, I’ve observed few software developers using “framework” and “library” interchangeably but they are very different. How? Let's read/review and learn…

Generally, you’ll notice that many software applications (coded in any programming language) have a lot of similarities and commonalities with a lot of standard business enterprise applications that you develop or code. Maybe the problem domain you are solving is different but it is very likely you are solving problems that are common to “most of the developers”.

What are some very common problems?

Though your focus is to add features to your project, you generally have some common things in many projects such as

  • Logging
  • Database connectivity
  • Authentication
  • Unit testing
  • Web application
  • and many more

A world without Frameworks and libraries

Think about a world where libraries and frameworks didn’t exist and imagine you have to solve the above problems and need to “write every line of code yourself” i.e. “start from scratch or zero” for every project, “re-invent the wheel” every time. Can you really imagine this? Scary isn’t it?

Now think, there is an open-source project that solves some of the above problems, aren’t you a bit more relieved?

Library

Libraries exist and are used to solve common specific challenges so that developers can work less about common problems and happily focus on the primary business problem that they are trying to solve.

For example (Being a Java person :)): Log4j — is a library that solves common challenges with logging for Java projects.

Libraries are

Reusable

Have well defined API

Developer is free to decide “when” and “where” to use it, “How” to use it provided by the library documentation i.e. “You call the library

Now imagine that many developers are solving the same problem “with the use of re-usable libraries” again and again that follow the same steps i.e. there are some specific patterns (a set of steps) that are occurring across many large scale projects ex: building web applications, mobile applications, integration applications, etc.

or simply imagine every time you develop a “web application” you need to start from zero (maintain sessions, listen to web requests) and then integrate with many libraries- Imagine doing this 10 times, 100 times, 1000 times, etc.

Now imagine there are teams who are providing this functionality with everything that you need to build large-scale applications with patterns and best practices included & awesome documentation. More relaxed isn’t it? Welcome to frameworks

Frameworks are

Reusable

Simpler but less flexible

The framework calls you — In technical terms this is called as “Inversion of control” — fancy favorite term :)

There are many examples of frameworks

Frameworks are shipped with everything you need to build large-scale applications, they are much simpler but less flexible.

When to use what?

  • Use framework — when you need to start up fast, keep it simple, follow best practices, adapt to the framework's way of doing things, lose a bit of control.
  • Use libraries — To solve common independent problems and you control when and where to use the library and you need the flexibility to write your own framework.
  • Use framework and library — Framework already comes OOB with many library dependencies, you have the luxury to plugin more libraries and use them confined to the framework flexibility.
  • No library or framework — Write everything yourself, why would anyone do this in the 2021 year :)

Will stick around…

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

@Anil's Notes
@Anil's Notes

Written by @Anil's Notes

Thoughts I add here are my personal notes and learnings only

Responses (1)

Write a response

Good article! In the end; I think you have two quotes that beautifully summarize this: you call a library, but a framework calls you (via forcing you to implement abstract methods or add annotations)

1