Python and Web Programming

For some years now that I’ve been keeping a decent amount of hack-ish libraries that do exactly what I want them to do. I have a library that provides me with a nice interface to different databases; another one keeps my sessions in check; others take care of cookies and encoding and decoding. To be honest, I never wrote any big website. I don’t really like web programming that much. But I do keep my libraries just in case. It’s like having that handy swiss army knife.

The other day, a co-worker asked me which framework he should use. He mentioned django and pylons I believe. There are plenty others, and the big difference is in how they do things and how good the interface they present is. Anyway, my answer was a manly one: write your own. I told him the time he would spend learning one of those frameworks and doing his own thing was about the same, considering he would realize the framework wouldn’t do exactly what he wanted. My answer has been bothering me for a couple of days and I’ve changed my mind. What I’m about to say is for all of you out there that want to start writing some websites in python.

Don’t write your own thing. It will be a nightmare for you to maintain it. You will write site specific stuff that you’ll regret later and then you’ll have to re-engineer some parts or even the whole thing. You will probably forget parts of the libraries that you rarely ever use and your documentation won’t probably match the (mostly good) documentation those projects (e.g.: django and friends) have. Not only that, but you will also regret you didn’t think about scalability and/or some other thing you should have thought when you wrote them. Believe me, my libraries have been with me for more than 8 years now and 8 years ago I didn’t think about scalability. I didn’t need to. Maybe one day I will and that is the day I am not looking forward.

My best advice to you is to learn one or two web frameworks and pick the one you feel most comfortable with. If you need stuff the framework doesn’t have, do the effort to extend it. In the long run, you will be better off that way. And if you really don’t want a complete web framework, at least look into some wsgi utility libraries to help you (e.g. werkzeug). Again, do not write your own thing.

As for me, I’ll be issuing a “rm -rf Projects/web-utilities” in my home folder.

P.S.: One of these days I may even write a tutorial on one of these frameworks.

Leave a Reply

Your email address will not be published. Required fields are marked *