Cheetah vs. kid: 1 - 0

I should have spent my Sunday doing a million other things, e.g. trying to clean up muttprint’s build system. Instead I decided to take a quick look at TurboGears and its parts. The Arch packages for it didn’t quite build so I ended up spending some time with CherryPy, Cheetah and Kid. I’m an utter beginner when it comes to “programming the web”, I’ve just never been very interested in it. It might be changing now though :)

CherryPy is truly impressive. A simple Hello World web service hints at just how easy it is to use. It’s written in Python, and it’s very pythonic indeed. However CherryPy isn’t what I wanted to write about. Another area I’ve not looked at is templating systems, I haven’t found a need for it yet. That’s possibly because I’ve never really understood what they are and what they do. That’s changing too.

TurboGears uses Kid so that’s were I started. I downloaded a simple example consisting of two files. The template:

The second file is the CherryPy modules that combines the template with values:

This, I think, is rather cool. Very clean, very nice. Still I thought it’d be interesting to take a look at Cheetah (one main reason was that their homepage mentioned that, which is funded by Paul Graham, uses it). It was a good decision, I think.

I wrote a Cheetah template producing the same output as the Kid template I downloaded.

The matching CherryPy module is very similar to the one above.

Now, what do I think? I guess the title of the post betrays my preference ;-)

I spent very little time reading documentation to do this. I needed some help to write the Cheetah template since I had to do it myself. However, I think that if I’d had a Cheetah example and tried to create a matching template using Kid, I wouldn’t be writing this right now. The Kid syntax just seems more confusing to me. I think I’d have to read more documentation as well as spend more time with Kid to reach the same level of confidence I have with Cheetah already after 30 minutes with it.

Now I just need to find some nice little project to verify that my first impressions are correct, both relating to Cheetah and to CherryPy. Any ideas?

Leave a comment