Tuesday, May 03, 2005

Python web frameworks and Rails

There's been a lot of discussion on the Python web SIG recently, prompted by the good press that Rails for Ruby has been getting. I'm not entirely sure it's going anywhere specific - it's not at all clear that there is a problem to be "fixed". But it does make me think once again about web development in Python.

I'm not actually a web developer. More than that, I have no actual requirement to produce any sort of web application in my job. But we do have some web applications, which we developed using Oracle's HTML DB. So to some extent, my view on Python web development is prompted by the question "why did we end up using HTML DB rather than Python?" Before I can talk about that, I need to start with a basic explanation of what HTML DB is. It's a web development environment, shipped with the Oracle 10g database - it gives you a web-based interface, which makes it very easy to build simple CRUD (Create Report Update Delete) applications. The key points are
  1. Rapid wizard-based development of CRUD applications
  2. Decent look and feel (tabbed pages, graphical buttons, etc)
  3. Lots of features to make sophisticated stuff "easy" as part of the initial application (built in search and pagination for reports, "are you sure?" prompts for deletes, things like that)
The nasty problems come once you have built your initial application, and are trying to maintain it. Like many wizard-style code generators, what you get from the wizard is complex and quite subtle, and you can get in a real mess when you try to modify it. And a lot of the slick features are produced by generating a lot of code, so when you try to add something similar without the benefit of the wizard, it's nigh-on impossible.

So every time we need to add a feature to the application, I feel that it's a maintenance nightmare, and we'd have been far better with a nice maintainable Python codebase. But I couldn't compete with the initial productivity of HTML DB (I was the Python advocate, a colleague built the HTML DB version).

So, the place I'd like to see more help for Python web developers is in the form of tutorial documentation and application templates. Something that looks nice (I don't have any design skills, and I suspect many Python developers are in the same boat). Displaying and updating a database table is pretty much the same regardless of the details of the table columns, so a generic CRUD application shouldn't be impossible.

I'm not too hung up on which framework I use - I'd like to see this sort of thing in any of them. Combinations I've tried to use have included
  • Twisted + Nevow
  • Quixote
  • CherryPy
For the database layer, SQLObject seems to be the most common choice, although non-SQL formats such as Durus aren't completely implausible. For my need, I'd want to store data in an Oracle database, and as SQLObject doesn't support Oracle at the moment, I'd be comfortable with a "raw" DB-API database layer.

So that's my impression - Python has lots of good things to offer in terms of maintainability and flexibility, but we lose on the "quick start" front. People want something "right now", and they don't seem to mind sacrificing longer-term maintainability for it. That almost certainly isn't true for "real" web developments, but in my environment, the quick intranet hack is king. For better or worse :-(

And that's where I see Ruby on Rails getting the attention - the 10-minute demo videos, showing how you can build an application from nothing in no time at all. So what if it's only a toy? It works, and it's a basis. Maybe Ian Bicking's Paste is going in that direction - I don't know, I've not looked closely at it yet. I can't get comfortable with the application generator style which Rails uses, and Paste seems to have picked up on. But that could start a whole new post, and I don't know Paste well enough yet to comment on it.


Blogger Ian Bicking said...

Paste and Rails don't do anything like what I think Oracle HTML DB must do. The idea is that every application has some structure, and some common files, and it's good to get those in place. And a little boilerplate also gets put in place; you don't want the generation to become an enabler of boilerplate, but some is bound to happen. I'd rather lean on generated code a little rather than on documentation.

May 04, 2005 3:57 am  
Blogger Paul Moore said...

Sorry - I didn't mean to give the impression that the Paste/Rails approach was like HTML DB. My issues with HTML DB are to do with the way the application is structured (inside an opaque IDE) rather than with the generation of an application template per se.

But I do feel that you've got to be very careful with code generation - rely too much on coding conventions and structures and you end up giving the developer another thing to learn (the specific conventions you need to adhere to in order to play nicely with the generated code). I'm not saying this is an issue with Paste - or even with Rails - but I've been hit before by cases where this is an issue (and HTML DB exacerbates its existing issues as a result of this, as well...) so I'm nervous of code generators for that reason.

I will get round to looking at Paste at some point.

May 04, 2005 10:52 am  

Post a Comment

<< Home