Luke Plant pointed out that Python, in contrast to Java and C#, makes templates unnecessary most of the time. In Java, a minimal program has a class definition and a method definition. In Python, the minimal template is an empty file.

The advantage of this is the ease of diving in and writing code. You don’t have to set up and/or use templates in an IDE, copy and paste, type boilerplate code in manually, or run a command-line script to get started.

As Luke points out, Django is the same way. This is one way it differs from Rails. In Rails you run script/generate.rb to generate a model from the database definition or a boilerplate view or controller. This is the way that is taught in the tutorial.

In the Django tutorial, the reader is instructed to simply type the code in and save it in a text editor. And as Luke points out, Template Inheritance makes it so adding a new page with the theme of the main page involves only three lines of code.

I also like how the models are structured. In Rails, you run script/generate.rb and a model file is generated, along with tests and a “migration file”, and you repeat this for each class (a class corresponds to a database table). In Django, you make a module file in the “models” directory, and each module file can contain however many classes you want it to. Sometimes it makes sense to have multiple models in a file (when there are tightly coupled models) and other times it makes sense to give a model its own file. Django gives the developer the freedom to choose how to structure the model directory.

I feel more in control when I use Django, because once the initial directories are set up, I add things starting with blank files and writing them using my own style. No boilerplate comments or tests are there to distract me. Also, since I don’t have multiple files being generated at a time, in different directories, version control is much simpler.

There are a number of other design decisions in Django that I like, some which differ from how Rails is designed, and some which are the same. The success of Django, I think, comes from being a well-designed and innovative framework, written from the perspective of its creators (the same could be said of Rails). I think this is why it has more mindshare and a bigger community than imitation frameworks.

I think that starting an open source project that imitates another as closely as possible, but on another platform, is a bad idea. Not only does imitating result in copying mistakes, it also results in copying style, which inevitably get mixed with the style of the copier. I think it’s better to figure out which features are needed from the existing project’s platform, and to adapt them, one by one, to fit well into the new project’s platform, and to the style of the developers and users of the new project.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.