It a world with frameworks and libraries now. Yes, it is. Now a days there are more articles on framework-1 vs framework-2 rather than language-1 vs language-2. Well, we’re not going through whether being a language guy is better than being a framework guy or not; but will discuss the differences between framework and library.
Definitions of Framework and Library
Well, the truth is; there is no definition of a framework or a library. Yes, there is no body which determines the standard definition of any of these two. But the two words are there in the community since a long time, so may be we can try to define these two using the concept in the community.
A framework is a reusable design or architecture which runs in a particular flow and executes the code you wrote with it. It is more like an aggregator which glues many libraries or even sometimes other languages and has the control to run things by its own order and priority.
For an example; you can think a framework as a coffee vending machine and the coffee power, milk, sugar etc are your code. The machine knows how to prepare the final output which is a drinkable coffee. It compiles the code of yours which are coffee powder, milk etc and also determines when to pour milk, when to add sugar and when the coffee powder. So the control remains with the vending machine and you have to put your ingredients in the right places; then only you will get coffee.
A library is meant to do a specific task only. A library doesn’t force you to go its own flow, but you can call any api of a library and use it the way you want.
If we take the previous example of coffee making, a library will be like a utensil in your kitchen. It’s you who decide which utensil to use when and while making the coffee, you decide if you want to put milk first or water, whether to add sugar or honey, how much to boil and every other thing. While making a coffee in your kitchen using the utensils; it’s you who have the control. You decide what should be the flow.
May be after reading the example of coffee making, you have created a conception in your subconscious mind that libraries are better. Well, don’t make that kind of concept, cause it’s completely situation based whether a library can be good for you or a framework. Both have advantages and disadvantages.
Framework vs Library
|Framework is a predefined design.||Libraries are meant to do some specific tasks only.|
|Have libraries preinstalled, knows which one is better suited for it.||You have to select your libraries.|
|Framework calls your code.||You call the library apis in your code.|
|The control in with the Framework if you’re using it.||The control is always with you.|
|Super easy to scaffold.||You need to scaffold your project manually.|
|Framework can use multiple libraries or even languages in it.||Libraries may have dependency on other libraries, but definitely not multiple language.|
|Fast development.||Requirement wise development.|
Stating a framework is better than a library or the vice versa will not be a better conclusion cause it’s always the use case and situation; not the tool itself. Frameworks are very useful to reduce your headache of dependencies, what to use and what not to, how to scaffold and design; but doesn’t give you the full control on your application. It’s very useful when you want to quickly develop something for any of your client. However using libraries can be useful as you will design your own application which will perfectly match your requirements; but managing dependencies, updating individual libraries and checking if one is breaking due to another is a big headache.
Still having issues?
If you still have issues understanding the above article, please leave a comment below and we will try to address that. In case you need help in your projects or understanding anything related to Programming; contact me, Paul Shan for assistance. Thank you for being a reader of VoidCanvas.