DEV Community

Discussion on: Library VS Framework - What is the difference?

Collapse
 
sarafian profile image
Alex Sarafian

I'm not sure the classifications are respected. Hence the fact that the lines have greyed out incredibly.

But if I read you well you make the distinction between writing code and not to utilize a provided functionality by a 3rd party. With that in mind, almost everything is a framework nowadays. Not disagreeing but fact is at this point that the lines have faded away. If for whatever reason you pass a predicate or an interface to a library function then what is it then?

Thread Thread
 
donut87 profile image
Christian Baer

Higher order functions (where you pass your own methods) are an interesting case. You plug in your code to then get the result for processing in your own code. So a framework inside a library.
So... yes, the lines are not that well defined and probably never were.

The general idea is still valid: If I am controlling the program flow, I am using libraries. If I am writing code to be plugged in somewhere I am using a framework. Might it be nodejs, .NET, Magento or Spring (Boot).

It is important to have the difference in mind. Especially when starting your live as a professional programmer. The inversion of control is what makes programs (frameworks) reusable and (more importantly) easy to change. Easy changes are so damn important these days...

Thread Thread
 
sarafian profile image
Alex Sarafian

There used to be frameworks (meaning I needed to write code) where the implementation with e.g. a class inheritance was kind of empty. Yet another blurry line. Any kind of code always controls the flow and I can't relate to this distinction.

If you ask me from my Dev years experience, I like your distinction because it kind of matches my practical understanding. I would consider a library something simple though potentially difficult, something were I don't 'care" about what happened inside and hence I need to log around it. I use the term log not at logging but at control and verification. At the moment I become too much involved with what happened then I'm out of a library concept. Maybe in other words, if I inject my code flow in the flow of what I consume then its not a library any longer. But then what about aggregator functions etc?

Again I'm not offering an official explanation but my personal interpretation. Nowadays I can't really place on either side with respect to some libraries, frameworks and components. With the exception of some clear libraries, everything else has become to mixed. At this moment I consider libraries stuff like a powershell module or aws toolkit etc. The code invocation does something compete for which I only care about the success very similar to an API call. I only need to control the flow some the 3rd party invocation.