The discussion on Aaron Swartz's blog about rewriting reddit & web.py illustrates a few amusing points about Python. Apart from the downright absurdity of some of the discussion so far -- general Lisp snarkiness, and Aaron's assertion that all bajillion Python Web frameworks suck (except for his, which isn't available yet...) -- I think a few truths emerge.
The main truth is that it's clearly too easy to write your own Web framework in Python. It's less work to code a few hundred lines of Python than it is to understand someone else's few hundred lines of Python; it's also easier to continue thinking like you already do than it is to adapt your thinking to someone else's API. And, most important of all, a few hundred lines of Python is really all you need for a fully functional Web app framework. Thus, our massive proliferation of Web frameworks. (As Harald Massa writes: Python: the only language with more Web frameworks than keywords</a>.)
Clearly, the only way to cut down on the number of Web frameworks is to make it much harder to write them. If Guido were really going to help resolve this Web frameworks mess, he'd make Python a much uglier and less powerful language. I can't help but feel that that's the wrong way to go ;).
Another truth that I stumbled over yesterday: it's much harder to write good, clean, maintainable, documented, tested code than it is to write a functional Web framework. Partly this is a matter of withstanding the test of time; partly it's a matter of development practices. If there's one thing I'd like to explore for my own projects, it's how to keep tests, documentation, and code all in sync. (Want to know how to do it? Come to our tutorial!)
I think the test for the future will be simple survival; this will be based on things like documentation more than on functionality. For example, Quixote, though powerful, suffers from poor documentation. CherryPy, which enforces a similar coding approach on apps, has an attractive, busy Web site. Getting started with CherryPy is simple; getting started with Quixote is not so simple. This really matters in the long run.
Picking a Web framework
The above thoughts occurred partly in the context of my own choice of frameworks for a new project.
I'm starting a new project for our Agile Development and Testing tutorial at PyCon, and I wanted to try something other than Quixote (just for novelty's sake, ya know?). My rough requirements were: must run on Windows; must not commit me to a database other than Durus, by e.g. requiring SQLObject; shouldn't be a huge framework (I'd like to distribute the entire thing in an egg); and needn't (shouldn't) be a full content-management system. So I took a look at QP, browsed around Django and TurboGears, visited web.py, and settled on CherryPy. (Actually, I started
on CherryPy and then discovered that their introductory "hello, world" example didn't work with their latest stable release, 2.1.0, and gave up in frustration. Then I came back to it after striking out with the others.)
So, why CherryPy?
Django and TurboGears are too much. Django is more of a CMS, and TurboGears commits me to too many packages.
QP is largely undocumented and doesn't run on Windows. (The former is a real problem: I spent 15 minutes trying to figure out how to run QP on something other than localhost, and couldn't manage.)
web.py? Not available yet. Maybe it will be, maybe it won't be... but it's awfully hard for me to evaluate a package based on 50 lines of documentation and no code, although I applaud the attitude.
CherryPy is just what I need: lightweight, fairly obvious code on my side, nothing complex required. We'll see how I feel in a week or two ;). I've already broken it once or twice, and I think the internal code is more complex than it needs to be (based solely on ~30 minutes of browsing around to fix the breakage) but I needed to commit to something before Grig keel hauls me... and CherryPy is clearly the best-suited of the things I looked at.
And it's got a really attractive Web site...
In other news...
is one of the coolest things to cross my radar screen in a while. (It's an AJAX-y way of adding comments to Web sites.)
I think there's a really good application somewhere in here; something combining Raph's trust metric stuff with Commentary to make a community-wide commenting/annotation system. (I put some work into such a thing earlier this year, but decided to focus on twill first.) I hope someone else writes it so I don't have to ;).
--titus