tags:

views:

178

answers:

6

I'm new to programming, so what is the difference between a Framework, a Toolkit and a Library?

+2  A: 

very, very similar, a framework is usually a bit more developed and complete then a library, and a toolkit can simply be a collection of similar librarys and frameworks.

a really good question that is maybe even the slightest bit subjective in nature, but I believe that is about the best answer I could give.

Gnostus
-1: You are missing the most important difference between a library and a framework: Inversion of Control.
Jörg W Mittag
I don't know Jorg - I think the term framework has been around for longer than IOC has been in common use. Framework may imply IOC but IMO does no necessitate it.
Groky
@Groky: I'm not sure. I have seen frameworks that are older than me for machines produced by companies that no longer exist, and *they* use Inversion of Control. Heck, every `.*rc` file in Unix is an example of IoC. Hook scripts in version control systems are an example of IoC. Shutdown routines on an IBM System/38 are an example of IoC.
Jörg W Mittag
A: 

Does it matter?

code4life
Should be in comments.
the_drow
I'd rather not...!
code4life
+3  A: 

A library is simply a collection of methods/functions wrapped up into a package that can be imported into a code project and re-used.

A framework is a robust library or collection of libraries that provides a "foundation" for your code. For example, the .NET framework is a large collection of cohesive libraries in which you build your application on top of. You can argue there isn't a big difference between a framework and a library, but when people say "framework" it typically implies a larger, more robust suite of libraries which will play an integral part of an application.

I think of a toolkit the same way I think of an SDK. It comes with documentation, examples, libraries, wrappers, etc. Again, you can say this is the same as a framework and you would probably be right to do so.

They can almost all be used interchangeably.

** UPDATE: ** As seen in the comments by Jorg and other posters, a framework follows an Inversion of Control pattern. I stand corrected in my interpretation of a framework.

j0rd4n
-1: You are missing the most important difference between a library and a framework: Inversion of Control.
Jörg W Mittag
It's not a matter of size.
Pascal Thivent
@Jorg - Inversion of Control is a design pattern. What does that have to do with a framework?
j0rd4n
@Pascal - I know and I qualified in my answer that it is more of an "implication" than a fact. Frameworks can indeed be small. As a developer, my brain thinks of the word "framework" as being more of a suite than a "library" that might provide a very focused set of methods. Just implied connotation is all I mean.
j0rd4n
Inversion of Control is the defining difference, and in fact pretty much the *only* difference between a library and a framework. Both a library and a framework are a collection of functionality. The *only* difference is who is in control. With a library, *your code* is in control and calls the library. With a framework, the control is inverted: the *framework* is in control and it calls your code. Not mentioning Inversion of Control when explaining the difference between a framework and library is like not mentioning breathing when explaining the difference between a whale and a fish.
Jörg W Mittag
@Jorg - Well said and it makes sense. I stand corrected.
j0rd4n
No worries. Downvote reverted.
Jörg W Mittag
+9  A: 
Jörg W Mittag
+1 for the right answer
Pascal Thivent
+1 for explaining Inversion of Control concept
Federico Cristina
A: 

same difference between a house, a mobilehome, and a trailer

Kenny
+5  A: 

Martin Folwer discusses the difference between a library and a framework in his article on Inversion of Control:

Inversion of Control is a key part of what makes a framework different to a library. A library is essentially a set of functions that you can call, these days usually organized into classes. Each call does some work and returns control to the client.

A framework embodies some abstract design, with more behavior built in. In order to use it you need to insert your behavior into various places in the framework either by subclassing or by plugging in your own classes. The framework's code then calls your code at these points.

To summarize: your code calls a library but a framework calls your code.

Pascal Thivent