The Artima Developer Community
Sponsored Link

Weblogs Forum
Library or Framework?

33 replies on 3 pages. Most recent reply: Sep 21, 2010 4:33 AM by Naeem Akram

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 33 replies on 3 pages [ 1 2 3 | » ]
Guido van van Rossum

Posts: 359
Nickname: guido
Registered: Apr, 2003

Library or Framework? (View in Weblogs)
Posted: Mar 14, 2006 8:54 PM
Reply to this message Reply
Summary
A quick observation on the difference between libraries and frameworks.
Advertisement

Neil Schemenauer made me see an interesting difference between frameworks and libraries. These are my words but it's really his idea:

A framework is just an application with a lot of hooks; you can design a framework in an entirely ad-hoc fashion by starting with an app that does one thing and trying to generalize in various directions. You can stop at almost any moment and call it "a framework". But a good library requires much more -- there, you need to start with requirements, abstractions and attempt at a minimal API that addresses the maximal set of requirements. Frameworks have no requirement to be minimal in size while maximal in features.


Ben Bangert

Posts: 6
Nickname: bbangert
Registered: Jan, 2006

Re: Library or Framework? Posted: Mar 14, 2006 10:56 PM
Reply to this message Reply
I think that's a pretty good breakdown. It also is a good place to show how WSGI is really changing things, since it implements such a minimal API that lets frameworks be broken down to libraries of useful web programming parts.

This isn't to say that "before WSGI" there was no ability to break down parts of a framework into library like package, it just wasn't as conveinent since there was no minimal API that anyone could build to and an ad-hoc API never seemed to spontaneously occur.

I'm not sure if twisted qualifies as a framework, or as a nice set of interwoven libraries. At which point does a well integrated set of libraries become a framework, or does it? Or is this really saying that making a good library is better than making a framework? ;)

Good libraries are also typically better tested in my experience, both because they're broken down into smaller chunks and because its easier to test them. If it's easy to test code, there's a significantly bigger chance the code will have solid unit tests behind it.

Vincent Oostindië

Posts: 5
Nickname: voostind
Registered: Dec, 2003

Re: Library or Framework? Posted: Mar 14, 2006 11:48 PM
Reply to this message Reply
I always thought the definitions were much simpler:
- A library is something you call from your code
- A framework is something that calls your code

From these definitions follow that as soon as a library provides 'hooks' so that it starts calling your code, it becomes a framework.

Guido, you (or should I say Neil) make it sound like designing a framework is a lot simpler than designing a library. In my experience the exact opposite is true. Where designing a library is, say, n times harder than using one, designing a framework is another n times harder than designing a library.

The problem is that not many people share that view, which is why there are so many crap frameworks... ;-)

Rene Dudfield

Posts: 2
Nickname: illume
Registered: Mar, 2006

Re: Library or Framework? Posted: Mar 14, 2006 11:59 PM
Reply to this message Reply
Some more differences between frameworks and libraries.

- A framework does not have as stable an api as a library.
- A framework is often hyped. As the word 'framework' is a buzzword, buzzwords often hang around frameworks. Buzzwords being marketing, marketing being manipulation.
- A framework is not as modular. Often you need to eat the whole framework to use small parts, or the parts are not used separately much.

Have fun!

Kevin Marks

Posts: 6
Nickname: kevinmarks
Registered: Jan, 2006

Re: Library or Framework? Posted: Mar 15, 2006 12:14 AM
Reply to this message Reply
Andy put it this way http://an9.org/devdev/why_frameworks_suck

I’m a library guy, I like a big set of tools available to call upon at need, I like to have a favorite hammer and a favorite saw and know the tricks for making them both fit on my belt without running into my legs when I am working on something. Framework people like the 5-in-1 lathe-press-drill-saw-grinder and figuring out the tricks to fit the piece of wood they are working on into the machine. When you have a framework everything will be lathe-press-drill-saw-grinded into submission, and you better read the manual otherwise the machine won’t even turn on.
Frameworks hurt sharing. I’d really like to give you this fork Jimmy, but you’re gonna need a knife and plate to use it. The framework checks out all your girlfriends for you, the framework won’t let anyone dirty get through, the framework will wait up until you get in, the framework will always find out were you’ve been, the framework keeps you healthy and clean. Frameworks embrace, extend and hold on to greedily.

Vincent Oostindië

Posts: 5
Nickname: voostind
Registered: Dec, 2003

Re: Library or Framework? Posted: Mar 15, 2006 12:18 AM
Reply to this message Reply
Kevin, thank you for making my point!

:-)

Scott Tsai

Posts: 3
Nickname: scottt
Registered: Jun, 2005

Re: Library or Framework? Posted: Mar 15, 2006 2:27 AM
Reply to this message Reply
The problem with this definition is that "map" count as a framework.

Not as useful in a language where function can be passed around like data.

Nicolas Nombela

Posts: 17
Nickname: nnombela
Registered: Feb, 2005

Re: Library or Framework? Posted: Mar 15, 2006 4:01 AM
Reply to this message Reply
kind of a stack from unspecific, simple and unmutable to specific, complex and mutable

language < libraries < frameworks < applications

Vincent Oostindië

Posts: 5
Nickname: voostind
Registered: Dec, 2003

Re: Library or Framework? Posted: Mar 15, 2006 4:37 AM
Reply to this message Reply
Actually, I think it's more like this:

application < library < framework

Anybody can write any application, in whatever language. Applications use libraries and/or frameworks. Writing a good library is harder. Writing a good framework is harder still.

But that's just me.

Matthias Benkard

Posts: 4
Nickname: kompottkin
Registered: Mar, 2006

Re: Library or Framework? Posted: Mar 15, 2006 7:06 AM
Reply to this message Reply
> language < libraries < frameworks < applications

It might even be:

library < framework < language < application.

Well... maybe one should distinguish between domain-specific and general-purpose languages.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Library or Framework? Posted: Mar 15, 2006 7:19 AM
Reply to this message Reply
I second this:

"application < library < framework"

I have created my share of applications, libraries and frameworks, and frameworks require the most imaginative approaches. It kind of suck that Web Frameworks seem much simpler to create, giving bad name to frameworks. 100 lines and a CGI approach and you have a "web framework". :-)

Kris Huggins

Posts: 1
Nickname: huggs
Registered: Aug, 2005

Re: Library or Framework? Posted: Mar 15, 2006 7:31 AM
Reply to this message Reply
I think Vincent has got it right, but I'd like to expand on it.

Both Libraries and Frameworks are trying to give you some added value.

Libraries take a concept/problem/whatever and try to encapsulate the implemenation of that in an easy to use API (e.g. XML Parsing, Http communication, Math Operations)

Frameworks try to define an organization of a larger application problem-space and give you things to make implementing applications in that problem space easier (e.g. MVC frameworks, App Server Frameworks, Web Service Frameworks)

Due to the nature of the problems they are trying to solve, your code calls libraries and frameworks call your code. I know there are exceptions to this, but it's a good rule-of-thumb. To confuse things further, frameworks usually come bundled with libraries that help you use the framework or help you do things that are usually affiliated with the problem the framework is trying to solve (e.g. valdiation library in a MVC framework)

Matthias Benkard

Posts: 4
Nickname: kompottkin
Registered: Mar, 2006

Re: Library or Framework? Posted: Mar 15, 2006 8:14 AM
Reply to this message Reply
Well... It depends on what you are comparing by. A comparison by difficulty of creation isn't what I was talking about (and it certainly isn't what I find most interesting).

General-purpose languages abstract the inner workings of the machine away.

Libraries abstract certain uses of language away and make them accessible in a more high-level manner.

Frameworks abstract the use of libraries away.

Applications abstract away the whole programming business.

From left to right, general-purpose languages, libraries, frameworks und applications become:

- more domain-specific,
- more abstract,
- more complex (of course: they're building on the less complex parts, after all).

Matthias Benkard

Posts: 4
Nickname: kompottkin
Registered: Mar, 2006

Re: Library or Framework? Posted: Mar 15, 2006 8:42 AM
Reply to this message Reply
Python, by the way, seems not to lend itself well for programming using frameworks, which is, in my opinion, a good reason to compare it to Ruby yet again (please bear with me :)).

The reason is that Python isn't magical enough (»explicit is better than implicit«, right?). Frameworks like Ruby on Rails can and do build on Ruby's metaprogramming magic, which lets you do a lot of really weird things.

I think that if you want to use a framework that does a lot of work for you in a magical and convenient, but sometimes opaque way, Ruby is the right choice. On the other hand, opaqueness isn't really a nice thing when you want to write an application that doesn't make use of a framework. In that case, Python is much more transparent in its behaviour.

The flipside of the coin, of course, is that frameworks impose a set of conventions and restrictions on the programmer, which is a good thing. As Python comes with a lot of conventions and restrictions already (»there's only one way to do it«), you don't need frameworks for that: libraries are enough.

There's one point left: frameworks are more convenient, but you have to really get into them before using them. If you know Python, you can use all of its libraries instantaneously. If you know Ruby, you can't do anything serious without learning a framework, too. (That's an exaggeration, of course, but it's kind of true.)

Thus, my conclusion: Ruby + framework + learning curve = Python + libraries + inconvenience. Or something like that :)

Tommy Carlier

Posts: 4
Nickname: tommyc
Registered: Oct, 2005

Re: Library or Framework? Posted: Mar 16, 2006 1:23 AM
Reply to this message Reply
I see a library as a module that implements some specific functionality, and a framework more as a platform to build your application on top of.

Flat View: This topic has 33 replies on 3 pages [ 1  2  3 | » ]
Topic: The Autoproxy Plugin - Part I Previous Topic   Next Topic Topic: ScalaTest Matchers Preview

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use