Pylons, or Python is fun again !

I’ve always liked Python. I started using it back in 2003, and it’s always been my first choice when writing stuff like sysadmin scripts, built tasks, RSS feed readers, that kind of thing.

However, my bread and butter is web development, and Python never had a compelling story for me in that field. Zope/Plone is horrendously bloated and complex (the infamous Z-shaped learning curve), Django is nice and well thought out, but I’ve found it more for developing dynamic web sites; it gets in the way too much for complex web apps. Turbogears started out well, but seems broken and lacking in direction these days. Then we have a number of smaller, or older, frameworks – web.py, Quixote, snakelets, WebWare…either too small a developer base, not actively developed, or just not what I’m looking for.

So, for web development, I’ve used J(2)EE, PHP and more recently, Rails. The latter has been the most fun, and Ruby is a nice language to work with. However, despite the deluge of Ruby hype and praise (much of it justified) I still prefer Python. Maybe it just fits my brain better, maybe it’s the scope and size of the libraries. I find Ruby harder to understand and debug, perhaps because of its Perlish syntax and metaprogramming tricks. This is not meant as flamebait: I just find Python easier for getting things done.

I can think better in Python; I find the process harder in Ruby, and often find there’s always a “better” way of doing it. As with Perl, I feel that while I may be a competent Ruby programmer, I’ll never be a Ruby guru (I think that may be the case of many Rails developers : they use Rails and its plugins without really needing to understand Ruby at any deeper level, thanks to Rails’ DSLs). However, the lack of a compelling framework, which would give me the same kind of productivity as Rails, has held me back from using Python for serious web projects.

Until I found Pylons. Unlike Rails and Django, Pylons is not marketed in any way; it is strictly minimalist, a “hacker’s framework”. This will not appeal to those who turn to Rails or Django for an out of the box solution with their decisions made for them (and nothing wrong with that, if you just want to get your project out the door), but it appeals to someone who enjoys building something just the way they want it, and dislikes “opinionated” frameworks that like to think they always know better.

Superficially, Pylons resembles Rails: it follows the same MVC pattern, supports AJAX, and uses Routes and helpers. That’s where the similarity ends. For starters, there’s no ActiveRecord: you provide your own model; most Pylons developers go with SQLAlchemy, possibly one of the finest ORMs in any language. Further, rather than just ERB on the menu, you can choose your own template engine. Myghty is the current default, but this is soon to be replaced with the awesome Mako, and you can use for example Genshi or Kid if you prefer something more XML-based, or Jinja if you like Django’s minimalist templates.

The most interesting thing about Pylons however is that it runs on Paste and WSGI, the Python web server gateway standard. You can run your Pylons apps on mod_python, FastCGI, SCGI, whatever you want, and build your own custom frameworks with Paste templates.

I can’t remember where I saw the quote, but David Heinemeier Hansson, the leading Rails developer, once compared Rails to a Ferrari. Well, a Ferrari is nice (and maybe not the best comparison, considering the performance of Ruby) but Pylons + SQLAlchemy + Mako is more like James Bond’s Aston Martin, customized by Q. It just looks like a normal car but comes with ejector seats, bulletproof glass and tons of gadgets. I know which one I’d like to drive.

About these ads

2 responses to “Pylons, or Python is fun again !

  1. Pingback: WordPress Wednesday News: WordPress 2.2 Released, Top Bloggers Blogging With WordPress, More WordPress Videos, and WordPress News : The Blog Herald

  2. Pingback: Top Posts « WordPress.com

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s