17 ms·
The hammer analogy breaks down from the get-go for me. The main distinguishing factor between a framework and a library is the classic "you call a library, but
by mcqueenjordan 5y ago
The hammer analogy breaks down from the get-go for me. The main distinguishing factor between a framework and a library is the classic "you call a library, but a framework calls you."
A better (but still imperfect) analogy might be buying a timber frame (with plan) versus home-rolling a stick frame from the ground up. With the planned timber frame house, the rough layout of the rooms and plumbing and such is somewhat predetermined, and as such it "calls you" in the sense that you're building out the amenities, but with the ground-up stick frame, you're explicitly making all the framing decisions too.
Like all things, there are bad frameworks, but scoped appropriately (simply) they can be incredibly useful. Just like houses, it turns out there are many ways in which web services are similar to each other and can benefit from a common framing.
- selfhoster11 5y agoI liken this instead to GOTO vs COMEFROM. A library is a GOTO statement, while a framework is a COMEFROM statement. Deity help you with the latter if you have problems and not enough knowledge about the framework.
- ItsMonkk 5y agoI always saw it as a tight-coupling with whatever framework you are working with but a loose-coupling with whatever library you are working with, but I like this more. It's much more emotional, almost psychological horror to a programmer.
- IggleSniggle 5y agoIt is...and then you can't help thinking about the "no-code" solutions. Anyway, also: 1. any application with sufficiently complex use cases requires configuration 2. any configuration can be made programmable 3. frameworks are application configuration with an open-end configuration programmability 4. ... 5. profit
- sumnole 5y agoTIL: https://en.m.wikipedia.org/wiki/COMEFROM https://en.m.wikipedia.org/wiki/COMEFROM
- zzbzq 5y agoIt invokes some of the particular absurdity of Spring or AspNet, though.
- Uehreka 5y ago> "you call a library, but a framework calls you." This is why I don't like when people say "React isn't a framework, it's just a library". Almost all of my React code is "called by React" with the one exception being `ReactDOM.Render()` (I don't count that since every other framework has some analogous "bootstrap" instruction). Now if folks want to argue that React only handles the "view layer" without providing a built in state management solution, that's absolutely true (and considered a separation-of-concerns positive by a lot of people including me). But I feel like so many folks just boil this down to "React isn't a framework, it's just a library" and then use that as a segue to negatively comparing it with their chosen tool.
- rictic 5y agoAnd with hooks that's become even more true, there's now a distinction between React functions and regular JavaScript functions, and you can only call a React function from another React function.
- purplerabbit 5y agoNot entirely true. Hookless function components can be called as regular old functions just fine
- serverholic 5y agoIt stops being a library when you structure your entire codebase around it.
- betenoire 5y agoOr any part of your codebase for that matter
- dexwiz 5y agoI think React's original goal was to be a library, but the community made it a framework, because they could not conceive of any other way to operate.
- austincheney 5y agoWhen you instead call it a factory analogy, exactly as the story reads, it suddenly fits well. Confusing a framework for arbitrary reuse is perhaps the best way to identify developers who aren't the mythical 10x developer. It is no different than confusing decoration for something useful when you are fending off destitution.
- 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.
- lliamander 5y agoYes, a house frame is closer conceptually to a software framework than a hammer, but I don't think that's relevant and would only undermine the rhetorical effectiveness of the analogy. The purpose of an analogy is fundamentally to describe some unknown thing (the subject) by comparing it with a different, known thing (the analog) that shares a common attribute with the unknown thing. The value in the analog is not in how many attributes it shares with the subject, but in how salient it makes the particular attribute you wish to highlight. Consider when a boxer is described as having a "glass jaw". Here, the subject is the boxer's jaw, and the analog is the material glass. It would be pointless to complain the analogy is a bad analogy on account of the fact that glass is translucent whereas the human jaw is not. The point of analogy is to highlight that the boxer is vulnerable to impacts to his jaw. The value of using glass as the analog is the readiness with which we can conjure the mental image of glass breaking; the translucency is irrelevant. Likewise, the point of this analogy about hammers and frameworks is that the author wanted something simple that would just work, and what he got was an over-engineered mess that requires considerable yak-shaving to get it to work. The fact that a hammer is more like a library than a framework is irrelevant, the point is that a hammer is something simple and familiar.
- Cederfjard 5y agoThank you, I appreciate this. It drives me crazy when someone dismisses an analogy because some other attribute than what’s actually being compared doesn’t match. Yes, you’re right, they’re not the same! If what you compared were exactly the same in every way, they would be the same thing! I think it’s part dishonesty, part emotional attachment to the things being compared (you should probably rarely bring Hitler into the mix, even if technically it works), and partly that some people just don’t understand analogies.
- lliamander 5y agoI think it's partly that it is easy, especially for technical people, to get hung up on details. And there is a good reason for this. It is often the case, especially with very technical topics, that the use of analogies can actually hinder understanding, because of the tendency to take the analogy too far[1]. Usually you just have to communicate a bit more on what the scope of the analogy is, and then it will make sense. There's also a subjective element in terms of what analog will be salient. Using the phrase "glass jaw" isn't going to have the same effect for someone who first thinks of Pyrex or bullet-proof glass. > Yes, you’re right, they’re not the same! If what you compared were exactly the same in every way, they would be the same thing! LOL! I've had that conversation almost word-for-word. [1]https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/ https://byorgey.wordpress.com/2009/01/12/abstraction-intuiti...
- deleted 5y ago[deleted]
- avgcorrection 5y agoHN: Use the right tool for the job. Also HN: Always and every time do use a carpenter analogy... or something involving woodwork.
- tgb 5y agoSo what do carpenters use for analogies?
- deleted 5y ago[deleted]
- bhelkey 5y agoSoftware Engineering. "Just imagine the facade is the frontend."
- smackeyacky 5y agoWhat happened to good old car analogies? This carpenter stuff is a little too waxed moustache hipster for me.
- friendzis 5y agoModern cars are incredibly complex and car engineering/manufacturing has really complex lifecycles. It is quite difficult to make an analogy with a thing that requires a lot of analogies to in the first place to explain. Carpentry/woodworking is somewhat simple. With a saw, planer, router, sander and a few primitive hand tools you can finish most woodworking projects. Most of the complexity of woodworking is in the accuracy/quality. Woodworking is simply easy to be conceptually* familiar with.
- Aeolun 5y agoI think a lot of programmers secretly want to be carpenters.
- detaro 5y agoAlso HN: lets take a few comments and pretend that's everybody on HN ;)
- agumonkey 5y agoThe thing is that computer guys got too much in love with the word and started to think framework === full blown 15-tier industrial facility. A good framework removes a chunk of work, guides you for the remaining part so you get there quickly but it should stay narrow if possible. here's a small framework: https://imgur.com/a/rBBdRSO https://imgur.com/a/rBBdRSO here's j2ee 4 understanding of the term: https://imgur.com/a/EH3vpXD https://imgur.com/a/EH3vpXD
- kazinator 5y agoIt's trivially easy to reframe the hammer as a framework; just take the point of view that what you're bringing to the table is the nail and the two pieces of wood (or other kinds of parts on which some type of hammer might be used). These pieces of yours are "called on" by the "hammering framework". This would all be easier if we had a metaphor-factory-generating factory.
- spmurrayzzz 5y agoI personally have often drawn the analogy of frameworks-as-general-contractors. Subcontractors (devs/engineers) are hired throughout the lifetime of the project and are the ones actually building all or most of the individual components, using tools (libraries), but their work streams are specified and directed by the GC. Some GC's are super opinionated (Rails/Django/Sails) and others kinda let you do what you want (Sinatra/Flask/Express). Neither disposition is inherently bad, but can have serious consequences as a direct result of both. I think this maps pretty well to the "framework calls you" concept you point out, a nod to inversion of control I assume.
- friendzis 5y agoIf we go down the woodworking analogy path, I guess the main difference between a library and a framework is that the former is a set of transformative actions and the latter is a set of building primitives. A really great analogy wood be a wooden window. A router/planer/saw in a workshop are libraries: they can take a piece of timber and transform that piece in a certain, somewhat adjustable way. A set of standard hinges/locks/mounts and router/drill sizes is a framework.