4 ms·
> The main distinguishing factor between a framework and a library is the classic "you call a library, but a framework calls you." This definition does seem to
by jaredklewis 5y ago
> The main distinguishing factor between a framework and a library is the classic "you call a library, but a framework calls you."
This definition does seem to match how I generally hear the terms used, but I think whether you call something or if something calls you depends more on the function of the library/framework than anything to do with the code itself.
I think we generally have "web frameworks" and not "web libraries" because if you are making an HTTP sever, then yea stuff is going to be calling you. ie.e the incoming HTTP requests are going to trigger your code. Now if I have a piece of code that extracts URLs from a string, that is obviously going to be called by me. That I can see, who is calling who has nothing to do with the design of the framework or library, and everything to do with the sort of task the framework or library performs.
Anyway, engineers obsesses over the distinction between library and framework, but it seems fairly mundane from my perspective.
- Someone 5y ago> because if you are making an HTTP server, then yea stuff is going to be calling you. Not necessarily. You could write the while True: request = getNextRequest() ... yourself. A web server library would have functions for parsing headers, creating http responses, handling cookies, generating html, etc., and could have data structures that make it easier to dispatch requests to individual handlers, but your code would be in the driving seat as to what gets called. Also a web framework could call a function to extract an URL from an incoming http request without any involvement of code you write. A framework provides a main method; a library doesn’t.