Why I’m loving DJango 0
Somewhere in the middle of the summer I started dabbling with web application frameworks. It’s about time, as I’ve been developing web applications for some time now and have about a few dozen or so under my belt with some pretty decently sized ones as well.
I started with Zend Framework. I’m not new to PHP. I’ve been developing in it for years and it’s relaxed syntax makes it my normal weapon of choice when I’m whipping up code. Hence, Zend Framework seemed like the logical choice given that it is backed by the same company that designed the PHP language. First, I had to wrap my head around some basic MVC stuff - I had not touched an MVC app since dealing with Java, and some of the fundamental ideas have different meanings in web applications. Then, I began hashing out some basic application stuff - database handling, user registrations, forms, etc. It all looked easy, when reading the documentation. But I found the implementation to be a challenge. Zend Framework’s big selling line is everything can be “decoupled” from one another so you can just use the bits and pieces of the framework that you want. I found that this often meant that the connection between objects sometimes seemed a bit convulted. After a lot of pain, I enventually had a basic shell to work with but I found it pretty unflexible. No doubt much of this was due to my lack of knowledge of the Zend Framework (and perhaps web frameworks in general) but I started to lose faith in it a bit. My goal for using a framework is two things: keep code simple, easy to manage AND increase productivity. I realized that while my code might have been easily maintainable, my productivity was sinking to extreme lows. Too much time spent reading documentation on non-native PHP objects and API’s.
I had read about Django a long time before - it intrigued me because it looked like a lot of fun to code in and had a low learning curve. I hadn’t programmed in Python since college though, and considered a language jump to be too expensive to productivity to make the jump. I was wrong.
One day, I got bored and downloaded Django and got it running (very quickly) on my Mac. I followed the provided excellent tutorial and shelled out an application, complete with admin interface, in hours. I was amazed. I was having fun.
I literally recreated one of my biggest web applications in Python in minutes. It’s excellent templating system meant I could worry about the back end stuff and design a pretty interface for it later. The great part about it is the framework turns things like database objects in to native python objects - meaning I’m not just learning the Django framework, but I’m also learning Python.
As if that isn’t enough, the philosiphy of Django itself strikes a chord with me:
- Keep things simple, don’t repeat yourself
- Abstract away things like database connections, queries, etc