3 ms·
If that were true, what would be the difference between a library and a framework? Is a library not also factoring out common parts? Or is a framework just a bu
by valenterry 4y ago
If that were true, what would be the difference between a library and a framework? Is a library not also factoring out common parts? Or is a framework just a bunch of libraries?
No, this definition doesn't describe what people understand as frameworks.
- bulatb 4y agoMaybe common structure, not common parts. "Framework" is a good description: it gives you the shape, you fill it in.
- valenterry 4y agoCare to elaborate the difference? In both cases common code is extracted.
- Ma8ee 4y agoThe difference between a framework and a library is that you call the library, while the framework calls your code.
- vidarh 4y agoThe article includes a crucial point about inversion of the flow of control. Somewhat exaggerated: You call into a library; a framework calls into your code. The old archetype of a framework might be one which expects to control an overall event loop for your application. In practice many things we would still recognise as frameworks allows you to undo that, but I still think it's a useful rule of thumb in that even many frameworks which technically allows you to remain in control of the overall flow tend to assume the framework will mostly dictate structure and flow.
- piaste 4y agoI would say the difference is that you can put a shim interface between your code and a library, allowing you to switch it out safely if desired. A framework is a library that is so pervasive that you cannot reasonably do so - your shim would just be a copy of the framework's API, and it would be exceptionally difficult to take a different framework and make it fit the shim. E.g. if you need to work with time zones, you can easily write out the function signatures you need, then look up any number of date-time libraries and make any one of them fit your shim. But if you need to 'manage data flow between backend and UI', and try to write out the function signatures you need, you're either going to be copying a particular framework's API or you're going to have a hell of a time implementing the same signatures for two different frameworks if one is one-way and the other is two-way.
- NoGravitas 4y agoNot every library is a framework, but some libraries are. For example, gp's description describes exactly how Django came into being.