Six Python Web Frameworks Compared 111
snydeq writes "InfoWorld's Rick Grehan provides an in-depth comparison of six Python Web frameworks, including CubicWeb, Django, Pyramid, Web.py, Web2py, and Zope 2. 'No matter what your needs or leanings as a Python developer might be, one of these frameworks promises to be a good fit,' Grehan writes. 'As usual, the choice is highly subjective. You will find zealots for each product, and every zealot is able to present rational reasons why their chosen framework is superior.'"
That One With The Fish Slapping Dance (Score:3)
Really. Best of the lot. Much more direct than those oblique, "All-England Summarise Proust Competition" bits. Leave the PhD at home, and make 'em larf a bit!
Re: (Score:2)
More and bigger tits in the Proust competition.
Re: (Score:2)
Re: (Score:2)
And interestingly twisted uses Zope's component architecture. It's pretty cool how the Python frameworks / apps try to play along with each other.
Re: (Score:2)
I was disappointed TurboGears wasn't there.
What?!? No Flasks or bottles in sight! (Score:4, Interesting)
Any python web framework shootout that features neither a flask [pocoo.org] nor a bottle [bottlepy.org] is not worth drink...err reading!
Re: (Score:1)
Re: (Score:2)
Agreed. As a Flask user, I reckon they missed a trick.
Re: (Score:1)
ironpython? (Score:2)
Re: (Score:1)
Not quite. EVE's server is built on Stackless Python. IronPython is a .NET language that runs on the DLR. Neither of which are really relevant to the article. The article is about web frameworks that run on Python, not language derivatives.
Re: (Score:2)
I think you meant EVE is built with Stackless Python [wikipedia.org]. Unless you where talking about a different EVE (I assumed EVE Online).
Re: (Score:2)
Re: (Score:3, Funny)
Re: (Score:2)
I think you meant EVE is built with Stackless Python [wikipedia.org]. Unless you where talking about a different EVE (I assumed EVE Online).
Stackless is another implementation of the language, upon which many web frameworks run.
Re: (Score:2)
stackless sucks balls by not supporting more than one cpu core
Re: (Score:1)
Re: (Score:2)
Depending on application design, python can support a surprisingly high level of concurrency. The main problem with the GIL is with multithreading but that doesn't mean python can't effectively leverage multiple CPUs. Furthermore, even with multithreading, if your application is heavily I/O bound, python frequently performs rather well. Its only in CPU bound multithreaded tasks and/or mixed loads whereby the GIL becomes a serious hindrance.
Re: (Score:1)
Re: (Score:2)
Nevertheless, due to the GIL only one thread can run at once.
Factually wrong. Period.
I encourage you to learn more about python threading and the GIL limitations because you seem to know only half of the picture - the worst half.
Only native python calls need block the GIL. This is why I/O almost never holds the GIL. Which means, I/O threads literally do run concurrently.
Seriously, it sounds like you have no idea what the hell you're talking about and only know tidbits here and there. The fact you're providing a video of what I already addressed is downright sad.
Re: (Score:1)
Yes, you're right - native code called from a python script does not have GIL limitations. And Python code cannot directly interact with the hardware, so at some point all I/O code is native x86/x64/ARM/whatever binary code. I'm not denying I/O bound Python code can benefit from multithreading. The point I am trying to make, that was first brought up by citizenr way up there, is that for CPU-bound tasks both Stackless Python and CPython are effectively bound to a single core.
I/O is irrelevant; I have never
Re: (Score:2)
EVE is built on IronPython. I'd say that's pretty impressive and worth a comparison when talking about web targeted python
IronPython is an implementation of the Python language, not a web framework. The six reviewed frameworks probably run on IronPython if one is so inclined.
time for a good eve' python summary. (Score:2)
yeah, lets summarize all of it. for fun.
0. eve runs on stackless python. (server and client. using dx9, not ogl (those bastards!)) .net (web frameworks might also run there, who really knows? or cares?)
1. stackless is cpython without a stack, hence the name. (one core limitation is not stackless' fault)
2. ironpython is python on
3. jython is python on java (at least django runs on that one)
4. these are interpreters. if you dont like it, i have others. also, i have to dock my mackinaw now. ice, ice, baby.
5. ?
Re: (Score:2)
Usability, yes. Career, no.
That's like asking whether getting an MBA in your 20s will be more beneficial from both career and competence perspectives than spending 10 years building actual businesses.
Re: (Score:1)
Re: (Score:2)
Not learning PHP will likely save you from hanging yourself with an Ethernet cable in shame once you discover how thoroughly PHP mutilates you mind.
After writing my master's thesis in PHP I have to take umbrage at your characterization of me and my ilk. Now if you'll excuse me my cats are relaying messages from the aliens and get cranky if I'm not around to interpret.
Re: (Score:3)
Not learning PHP will likely save you from hanging yourself with an Ethernet cable in shame once you discover how thoroughly PHP mutilates you mind.
Curse these flimsy UTP [wikipedia.org] ethernet cables! They keep breaking when I put my full weight on them. Where is thickwire [wikipedia.org] when you really need it?
Re: (Score:3)
Re:Doesn't matter which. At least it's not PHP! (Score:5, Informative)
How much programming do you know now? Because if the answer is "very little" (or none), then you would do well to stay the hell away from PHP for as long as you can. PHP is useful because it's widely available on shared hosting servers, but as a language it is truly terrible. It will confuse you and leave you scratching your head at how to solve a problem at the same time that it's teaching you bad habits.
Just for starters, PHP's library is full of inexplicable inconsistencies. For example, the arguments for mysql_query are "querystring, resource." The arguments for pg_query (for PostgreSQL) are "resource, querystring." Why? Don't ask. This is just one example of the typically slipshod way PHP has been put together. Note, also, that in both cases "resource" is optional. Die-hard PHP programmers will surely chime in at this point, telling you you're much better off using a database abstraction layer anyway, but which one? The PHP documentation lists four, but there are more than that.
Python overall has been designed with much more care and forethought, is a much better language, and doesn't deserve to be put down like lame horses and PHP should be.
That said, if you want to get more Web work, faster, learn PHP.
Re: (Score:1)
I'm not understanding how that's a bad thing. PHP isn't the only language that has multiple extensions with overlapping functionality. The answer to "which one?" really depends on your needs (which is why there are multiple extensions in the first place). PDO is probably the most commonly used.
Re: (Score:3)
The answer to "which one?" really depends on your needs (which is why there are multiple extensions in the first place).
I disagree. The reason why there are so many extensions that do more or less the same thing is that nobody in the PHP community can agree on a good way to do something. And this goes double for the core language, which includes features that do the same thing already, except that the features in the core language are so bad that you should skip them and start looking for an extension to do it right. The end result is no two PHP programmers will be doing things the same way, because they each picked a differ
Re: (Score:2)
In mysqli_query() the order is ressource, string. Don't use an outdated extension - problem solved.
Re: (Score:1)
PHP is not very good for writing real web applications. It's a real PITA for doing anything sophisticated. The Python + Django combination will allow you to quickly create web apps of various complexities (you can use it to throw together a quick website or use it for large projects).
I'd advise you to go with Python + Django but learn some PHP as well, just so you know what tools you have available to you. PHP has its place, as does Python and Django. Always try and use the best tool for the job :)
Re:Doesn't matter which. At least it's not PHP! (Score:5, Insightful)
Career-wise, there are WAY more PHP jobs than Python jobs, so if you're looking to be employed by someone else, PHP first (but don't stop with just one). If you're going to be doing your own projects, Python has evolved in a much more logical way than PHP.
It depends on what kind of web development career you want - there are lots of specialties these days. Learn PHP, and learn all the associated web technologies REALLY WELL (html, css, javascript, ajax, etc). Get really good with an IDE (probably Eclipse). Learn how to use Photoshop and maybe Flash (or Edge). Learn SQL - MySQL especially, but also maybe some NoSQL tools. Learn the backend stuff like memcache, hadoop, etc.
The more stuff you know, the more employable you will be.
Learn how to write well. Being able to express yourself goes a long way in a technical career.
Re:Doesn't matter which. At least it's not PHP! (Score:4, Informative)
Oh, and learn jQuery after you learn Javascript (not 'instead of').
Re:Doesn't matter which. At least it's not PHP! (Score:4, Interesting)
One thing to keep in mind with modern web development:
Learning the server side language is only a small fraction of the total learning curve.
You will need to eventually learn databases, a smattering of basic sysadmin skills, Javascript, HTML, CSS, a bit of HTTP, and not least the web frameworks or associated libraries and APIs themselves.
With most frameworks sorta looking like MVC (whatever that ends up meaning these days) and the basic problems being the same, part of the learning curve of one system will help with learning another. Most web developers worth their salt will end up knowing multiple frameworks and server side languages anyway.
You should actually try out both Django and something like Symphony2 (PHP) yourself to see which you prefer. Spend a week or so on each running through tutorials and creating demo sites. You'll soon get a feel for whatever you prefer.
Career wise, language popularity isn't necessarily the most important thing really. Niches can still be profitable depending on where you are and supply/demand etc. eg there are plenty of PHP jobs, but standing out from the hordes of barely capable PHP developers can also be difficult for the less experienced.
If you have to just start with one thing though, Django is a good choice. It's the most popular Python framework, and Python is a much better language for learning good coding habits than PHP. And if you later decide you prefer PHP (or the PHP job market), Symphony is still pretty similar from an architectural / functional point of view and having another language behind you gives a better idea of what not to do in PHP. Or if you end up really liking Python, you have lots of other options later for other frameworks if Django ends up being a bit limited or not quite to your taste.
Just stay flexible and open minded, and know that web development will require ongoing learning no matter what.
Re: (Score:1)
Will learning a Python framework (I am looking at Django) be more beneficial for me from both career and usability perspectives than PHP?
Depends ;)
PHP's usability is clearly inferior (and looks worse, something that actually makes a difference if you look at code a few hours a day).
PHP is used in more in simpler CMS engines (with obvious exceptions like Drupal), so if you are targetting smallish local shops looking for a relatively simple website, then I would advise learning PHP. Python on the other hand is mainly used in more complex environments (see the CMS/web programming framework Plone). A bit more work to get in, but it's also eas
Re: (Score:2)
I'd say pick any two of the Three Ps of web programming (Perl, Python, and PHP) and you'd be OK. Don't start with PHP.
Perl and Python combined should give you enough job opportunities and make picking up PHP later a snap, while PHP plus either of the others should keep you from being a bad PHP coder.
As a third one to try to get experience in, Java or asp.net are good choices. Both are annoying in their own ways, but IMO Java's nicer to work in. Don't forget Javascript, too--it's very different from most
CubicWeb? (Score:1)
Re: (Score:1)
Re: (Score:2)
The omission of Flask and CherryPy was indeed quite curious as they're certainly very popular.
However I think that Twisted/Tornado are outside the scope of the article given that they aren't exactly web frameworks but rather components that can be used in web frameworks.
I think the question that matters most of the time is not really "which framework" but rather "which database/ORM" or also "which templating system".
Re: (Score:2)
It's made by Logilab, who also made pylint, a static code checker for Python. The logilab.org site runs on CubicWeb, so they are eating their own dog food.
Flask? (Score:1)
If you are browsing for Python frameworks, you should give it a look.
Zope 2, but not Zope 3? (Score:2)
Just asking.
Re: (Score:2)
Zope 3 is dead. It is a discontinued project. Zope 2 is the branch that is going forward. Bluebream is a sucessor to zope 3 but it is not an upgrade to zope 2. It was actually discussed that zope 2 should be renamed zope 4 to make that more clear but it was decided not to do that since it would confuse people.
Re: (Score:2)
Interesting. I'm glad I asked!
Oh, python (Score:2, Interesting)
I dig python. I chose python + sqlite to clean data instead of excel and vba.
1.) It's free (speech/beer)
2.) It's multiplatform
3.) It runs on my freebsd machine as easily as on my mac desktop
4.) I can use a sqlite database exactly like a postgresql or mysql db in the python api (handy).
5.) It added a line to my resume!
etc etc
I hope to never use python as a web designer (because I don't want to be a web dev - no offense). But, I definitely appreciate its generality.
Re: (Score:2)
agreed. i usually started to write pseudocode in python. which is handy. since you can run your pseudocode.
Re: (Score:2)
I use bash to clean data: rm / -rf
In-depth? (Score:3)
Surely you are joking?
Re: (Score:1)
Considering that most people these days have an attention span of 140 characters it was indeed in-depth.
Re: (Score:2)
Yeah, I think calling that article a superficial once over would probably be overstating its depth.
Anything ready for the real world yet? (Score:3)
The last time I tinkered with Django, I tried writing a simple CRUD app for an existing database at my job. After wasting a few hours learning how the ORM package works and setting up my models, I came to realize that Django does not support database tables with composite primary keys . In other words, it doesn't work with almost any legacy database that you will find in any enterprise shop on the planet. It wasn't worth re-working the schema, so I had to retreat back to Spring MVC and wrestle its XML.
I'll give Django credit, though. It's still several steps ahead of Ruby on Rails, which my last experiment taught me doesn't support more than one database per app !
I make a point to take one these "dynamic language" frameworks for a spin every 6-12 months... because I keep hearing that they are leapfrogging Java, and Oracle is destroying the universe anyway, and my career will be over soon if I don't migrate my skillset. So far I'm just not seeing it, though. These frameworks may be useful for simple non-commerce apps, stood up in a hurry by junior-level devs... but none of them seem remotely ready for any of the realities I deal with day-to-day when working for large companies or handling commerce.
Re: (Score:1)
Try SQLAlchemy. It's simply awesome. The ORM by and for people who actually know relational databases. No "composite keys not supported". No "Legacy DB" FUD phrasing like Rails. Use it with Mako for templates and whatever web framework. Pylons/Pyramid works, as do others I'm sure, but to me the far more important choice is the ORM and templating system. The rest is just glue.
Re: (Score:2)
Re: (Score:1)
Welcome to slashdot. Its the original home of, "the retarded kid has a stick and he's not afraid to use it."
Re: (Score:2)
SQLAlchemy (Score:2)
Re: (Score:2)
The last time I tinkered with Django, I tried writing a simple CRUD app for an existing database at my job. After wasting a few hours learning how the ORM package works and setting up my models, I came to realize that Django does not support database tables with composite primary keys . In other words, it doesn't work with almost any legacy database that you will find in any enterprise shop on the planet. It wasn't worth re-working the schema, so I had to retreat back to Spring MVC and wrestle its XML.
I'll give Django credit, though. It's still several steps ahead of Ruby on Rails, which my last experiment taught me doesn't support more than one database per app !
I make a point to take one these "dynamic language" frameworks for a spin every 6-12 months... because I keep hearing that they are leapfrogging Java, and Oracle is destroying the universe anyway, and my career will be over soon if I don't migrate my skillset. So far I'm just not seeing it, though. These frameworks may be useful for simple non-commerce apps, stood up in a hurry by junior-level devs... but none of them seem remotely ready for any of the realities I deal with day-to-day when working for large companies or handling commerce.
I haven't used any of the frameworks reviewed since where I work we have our own Python web framework. However, the thing that immediately struck me when reading the reviews is that several of the web frameworks have there own database abstraction libraries and/or ORMs, which seems wrong. Why should the DB access be tied to a web framework? I'd rather choose a framework that's good at the web stuff and a framework that's good at the DB stuff and not have one come with the other. I've been dabbling with SQLA [sqlalchemy.org]
Re: (Score:1)
Why should the DB access be tied to a web framework?
I belief it's part of what makes something like Django tick. All you do is create an object comparable to a non-web Python program and you work with it as such, the framework handles the rest. Or ask your question the other way round: why should you have to deal with the back-end when all you want to do is write a web-app.
There's nothing wrong with your view and it's great if it works for you but it leads to what you describe: "we have our own Python web framework". I think you can imagine Django being usef
Re: (Score:2)
It's somewhat convoluted, but you could make it work. You'd need to add an ID column, make that the primary key, add a unique-together constraint for those fields, and add a bit of custom SQL to create an index on those two fields (there's a way to put this in a file and make it run automatically).
Re: (Score:2)
Let me stop you at, "You'd need to add an ID column...".
In a large enterprise shop, changing the schema for an established legacy database generally is not an option. There are usually dozens of live production applications tied into the existing schema, and management would never sign off on introducing needless risk for all of those.
Even if you did get approval to move forward, you would need to time and QA resources to fully regression test all of those apps (assuming you identified them all and didn't
Re: (Score:2)
I quite like Django's ORM. It's not as powerful as SqlAlchemy but it is easy to learn, and the Django guys put a lot of effort into documentation. I learned SQL the traditional way years ago and I'm still glad I did, but I don't particularly miss writing my own queries. If the ORM generates bad or slow SQL I can still drop to raw SQL.
But I get your point re legacy systems. It sounds like a nice challenge to implement composite keys for Django.
The big and powerful framework is Zope. Zope was also a driving f
Re: (Score:2)
You are wrong about the frameworks not being as powerful as Oracle etc, but I don't blame you since it takes a long time to become familar with a large framework. I would also not have time to learn eg. any big Java framework, so I'm in the same boat.
I'm not trying to be a jerk, but I'm not sure you have a basis for comparison. "Oracle" is not a Java framework, it's just the company that acquired the Java trademarks from Sun. I guess they own the trademark for JEE too... but that's not really a "framework", and its direction isn't so much identified with Oracle. Java web frameworks would include things like Spring (used by most shops these days), Seam, Struts, Wicket, etc.
Anyway, I have written apps in "dynamic language" frameworks... including Rai
Re: (Score:2)
My hammer would be called Plone. It runs on top of Zope. I love it but it is not a good fit for small systems.
Re: (Score:2)
Hey, just wanted to chime in a bit here. As many others have mentioned, SQLAlchemy supports just about everything pretty well, but IMHO it got the disadvantage of being way too complex for 90% of what you want to do (and also have confusing docs).
Django's ORM is much smaller, more compact, sacrifices some advanced features, and is (again, IMHO) much easier to work with, and got solid docs.
But, here's the thing. You can use SQLAlchemy in Django. You can even use both Django ORM and SQLAlchemy in the same pro
Re: (Score:1)
Yes, but when you have to deal with an *existing database* that has composite keys, you're out of luck.
Re: (Score:2)
These projects sometimes (usually?) have some sort of tutorial showing how to set up a simple website. I know Django and TurboGears do; I'm not sure about the others.
Web.py is great (Score:2)
Web.py is great for developing web services. Really, really quick and easy to learn. The documentation is probably about a 7 though, I agree with that. However, I'd give it 9s on everything else.
Web.py+mimerender is pretty sweet. Check out the example code here:
http://stackoverflow.com/questions/713847/recommendations-of-python-rest-web-services-framework [stackoverflow.com]
I find this infinitely more comprehensible, pythonic, and nice to work with than the other Python web frameworks I've seen. I've never really used Dja
How does Turbogears compare these days? (Score:2)
It was probably the best all-in-one python webapp-building mega-framework 5 years ago.
I found Turbogears great because it eliminated (unnecessary) choices (i.e. all mandatory convention),
and pretty much just worked out of the box (modify a working trivial webapp was the way you got started.)
How does its latest version compare to these others? Anyone have an opinion on that?
If TG is no longer competitve, why, and which other one has its good features like I described above?
Re: (Score:1)
Not sure where it is at now, I bought the book when it was *current* and really liked the framework, but didn't get into developing a live app with it at the time.
When I recently went back to look at using it, they have replaced 2 or 3 or more of the base libraries and the book appears to be redundant. Haven't yet investigated enough to see if there are clear and useful instructions available online for getting up and running with the latest version, but I would like to see an in-depth guide to things tha
Re: (Score:2)
TurboGears never managed to get enough momentum in terms of code contributors to really prosper. You can get a feel for some of the saga just by reading the project's Wikipedia page [wikipedia.org]. It lives or dies based on the contributions of a few key people, and that group had the misfortune of stalling right as Django in particular was really picking up a lot of steam around two years ago.
Re: (Score:2)
"had the misfortune of stalling right as Django in particular was really picking up a lot of steam"
which is really too bad because Django is freakin' weird. (e.g. it calls a controller a view, seemingly just for fun.)
missing tornado.... (Score:2)
Re: (Score:2)
Yes it is the only one I like, very close to app engine and extremely fast.
Re: (Score:2)
I have written a few apps using Tornado... So far it is my favorite framework for developing rich web applications. I contributed code/patches that the Tornado devs used to add SSL support to the framework. Also, just the other day I completed a Kerberos/AD/SSO authentication module for Tornado (I'll be making it available soon I hope).
My favorite feature of Tornado is the built-in support for WebSockets. It should also be mentioned that it is one of (if not THE) fastest Python web frameworks.
I also wan
Performance and resource usage? (Score:2)
Re: (Score:2)
Any sort of useful benchmarking here would take an article a hundred times more difficult to write than the work that went into this one. Performance for this class of applications is so dependent on workload that the idea of evaluating their speed can't happen usefully without a large amount of testing. There are possibilities for almost every layer that multiply together for the number of configurations to consider. For each framework, you'd need to evaluate each of the web server possibilities, each o
Tornado (Score:2)
The only python one I have tried and liked so far is tornado.
"Six Python Web Frameworks Compared"? Holy crap. (Score:2)
Really? (Score:2)
Oh really? The subject is "python web frameworks" and you assert that a ruby implementation will score well in this competition? I gotta ask, what version of python does "ruby on rails" support?
Re: (Score:3)
Re: (Score:2)