I’ve a lot of interactive websites I’ve been wanting to do lately. After learning Python earlier this year, I’m wanting to write all these projects in Python versus something conventional like PHP. I’ve come to the conclusion that web development with Python sucks; it’s no wonder it’s not being used very much. There are too many frameworks, many doing similar things in different ways, or doing totally dissimilar things in totally different ways. I’ve been spending the last week reviewing several different frameworks and deciding which ones I thought were best.
Of the frameworks I’ve looked at (of which I am too lazy to list), the one that seemed the best is Twisted, along with a slick template language called Nevow made to be used with it. Twisted is a generic network framework supporting tons of protocols: HTTP, IMAP, SSH, IRC, etc. Twisted.Web is a part the web server part of Twisted; using it, you can easily create application servers, though not necessarily the applications themselves. This is where Nevow steps in. There are several things I like about Nevow, including:
- HTML templates with Nevow-tags: no code embedded in templates, thus templates remain easily editable by a WYSIWYG editor (not that I’d ever use such a thing)
- Strict separation of data and presentation: “data” and “render” methods, which are designated in the template
- Not strictly tied into Twisted: it is WSGI compliant, as well as can be used with normal CGI programs and probably mod_python
- Stan: easy way to generate XML (i.e. HTML) with Python code
- AJAX: the whole pages-can-update-themselves-without-refreshing thing that has been made popular by Google
After hearing about Ruby on Rails, though, I really liked this object-database mapping RAD (rapid application development) model that has come up lately. That is, rather than dealing with SQL directly, you just create, delete, modify, and use the relationships of objects and lists of objects. Changing attributes/certain methods prompts automatic updates in the database–no explicit work needs to be done by you.
Nothing against Ruby, but (at the moment) doesn’t have the huge assortment of modules that Python has. Most of which are counterparts to C APIs. I do a lot of systems and “specialized” programming (don’t ask me to explain what that means) and I find myself having to resort to UNIX APIs all the time–not everything is just manipulating stuff from a database. And, honestly, I don’t really want to learn a new language.
Then, just an hour ago, someone pointed me to Django. It’s new. Like last week new. It’s basically a Ruby for Rails, but in Python. Just glossing over their website, neat features I noticed it has:
- Object-database relational mapping ala Ruby on Rails (see above) from objects to database tables
- Automatically-created administration interface that can create/delete/manage your objects: you don’t have to spend time coding administration interfaces
There are some things I don’t like about Django so far, however. The templating language… Eh. It’s not the beautiful presentation-separated-from-logic design that Nevow’s templates are. It’s also most stable with mod_python (which I personally do not like), and the application server it includes notes to not use it for any kind of production use. I’m thinking whatever I come up with is going to be some hybrid between Twisted/Nevow and Django.
What does bug me about most these APIs is speed. Python isn’t really the fastest language ever. One of the nice things about the Python standard library is that a lot of it is written in C rather than Python, so stuff is fairly fast. All these layers of abstraction however (all of which has to be interpreted) adds a lot of overhead, and I’m wondering about the speed issues. I’ve yet to roll out any kind of application that uses them, though, so at this point I don’t know.