What’s the difference between a library and a framework?

Library
A library is a reusable piece of code which you use as it comes i.e it does not provide any hooks for you to extend it. A library will usually focus on a single piece of functionality, which you access through an API. You call a library function, it executes some code and then control is returned to your code. An example of a good Java library (or libraries in this case) is Apache Commons: http://commons.apache.org/

Framework
A framework is a piece of code which dictates the architecture your project will follow. Once you choose a framework to work with, you have to follow the framework's code and design methodologies. The framework will provide you with hooks and callbacks, so that you build on it – it will then call your plugged-in code whenever it wishes, a phenomenon called Inversion of Control.

A framework will usually include a lot of libraries to make your work easier. Examples of (web) frameworks are:
 * Ruby on Rails: http://rubyonrails.org/
 * Tornado Web: http://www.tornadoweb.org/
 * CakePHP: http://cakephp.org/

Answer by Alex Michael:

Library
A library is a reusable piece of code which you use as it comes i.e it does not provide any hooks for you to extend it. A library will usually focus on a single piece of functionality, which you access through an API. You call a library function, it executes some code and then control is returned to your code. An example of a good Java library (or libraries in this case) is Apache Commons: http://commons.apache.org/

Framework
A framework is a piece of code which dictates the architecture your project will follow. Once you choose a framework to work with, you have to follow the framework's code and design methodologies. The framework will provide you with hooks and callbacks, so that you build on it – it will then call your plugged-in code whenever it wishes, a phenomenon called Inversion of Control.

A framework will usually include a lot of libraries to make your work easier. Examples of (web) frameworks are:

What's the difference between a library and a framework?

Advertisements

Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s