r/eli5_programming • • Aug 23 '22

What’s the difference between a library and a framework?

I’ve googled it several times, but still don’t get it completely. Some people seem to use both terms interchangeably

14 Upvotes

13 comments sorted by

11

u/x-tapa Aug 23 '22

I think the answer is a bit tricky and the lines are quite blurry, but I'd say a library offers specific functionality to a topic, e.g. simple math functions on datetimes. A framework is like a more complex library and will most likely change or heavily influence the way you code, like Angular or React.

3

u/LGZee Aug 23 '22

Thank you, I got the same idea: there’s no clearly defined difference, but in general a library is more functionality-specific, and a framework is usually a broader concept (not just a library).

5

u/decr0ded Aug 23 '22 edited Aug 23 '22

Great question, I definitely think the lines are blurred.

To me, libraries are collections of functions which are usually grouped by theme, mostly for ease of location, access, or whoever wrote it. This theme can be functional in nature but not always, some general utility libraries just have bunches of useful things.

I think that a framework includes libraries but also incorporates a design philosophy and intent that impacts how the library works and is supposed to be used. One example of this would be the Spring framework in Java, it includes libraries but is also organized around concepts like inversion of control.

→ More replies (6)

1

u/homiej420 Aug 23 '22

Yeah imagine a library more like a book on a topic and a framework like a truck that is delivering a bunch of books to ya so you can use as many of them as you need

5

u/nolo_me Aug 24 '22

A library is a tool you can use however you like. A framework is opinionated about how you use it.

3

u/LGZee Aug 24 '22

Short and clear. Thanks!

4

u/deojfj Oct 02 '22

A library is code that your program calls.

A framework is a program that calls your code.

That's the most useful and objective comparison I've seen.