4 ms·
The best distinction I've read is: When something is a library, your code calls functions on it. When something is a framework, it calls functions on your cod
by syspec 6y ago
The best distinction I've read is:
When something is a library, your code calls functions on it.
When something is a framework, it calls functions on your code
- brundolf 6y agoI think that can be more precisely defined as Inversion of Control: https://en.m.wikipedia.org/wiki/Inversion_of_control https://en.m.wikipedia.org/wiki/Inversion_of_control which has a strong association with "framework" thinking, but I think it's still useful to treat them as distinct concepts
- galaxyLogic 6y agoThat seems like the only precise definition I've seen for what is a framework. From this perspective it would be interesting to see some rationale for why libraries not frameworks. I would say that libraries are not the opposite of frameworks at all. You can have a library which contains a set of framework-classes.
- uryga 6y agoit's a rough rule of thumb at best though – higher-order-functions or other things that take a callback blur the line a lot (IoC, what a sibling comment said). or say a library has an event-loop, or maybe does networking and you only provide some handlers – would that make it a framework? i guess it's about frameworks being "the main thing happening". i.e. a framework controls the whole program's execution, occasionally yielding control to your code. which is a bit wordier to be sure :)
- grecy 6y agoI'd add to that and say When something is a framework, it calls functions on your code AND it does a lot of the heavy lifting for you. I studied Frameworks in my Software Engineering degree, but really had no appreciation for them until developing large software in WebObjects. Until you've extensively used a well-written Framework, libraries seem great. After, you realize a library just helps you here and there, but a Framework is so much more.