Rails and Django, a comparison

Continuing where I left off last time comparing Ruby and Python, I’m going to continue this small series by talking about the comparisons between two commonly used frameworks for each of these languages: Ruby on Rails, and Django for python.

It’s not a fight, just a comparison!

First, some similarities

Both are open-source frameworks used for the development of applications and for the most part, have a lot of similarities.

1. Architecture

Both use the MVC (model-view-controller) web application architectural design. One little, but important, detail for Django is that it replaces the word Controller with Template, making it MVT.

As a refresher, the MVC or MVT architectural pattern that divides an application into three parts: the model, the view and the controller, or template, depending on the framework. It separates data models from business logic(controllers/templates) and visual representations.

2. Community Support

It’s 2020, so these frameworks have been out for quite some time (about over a decade for each). Since then, the usage of both has grown considerably. Major companies that use Django include Spotify, Youtube and Instagram. Well known companies that use Rails include Github, AirBnB and Shopify. In both cases, both frameworks are very mature, and have lots of plugins and packages for Django and lots of Gems for rails. There’s not much need to reinvent the wheel when developing for both.

And now, some differences

Quite a lot actually, John Mulaney

It’s all about the languages

In my last post about Python and Ruby themselves, I explained how there were different philosophies that dictated how the languages were designed, which in turn, influenced how they are used. These philosophical differences are expressed through the frameworks as well.

The thought behind python development is that there should be one solution and one solution only to a problem. While in practice that doesn’t work out that way sometimes, for the most part, it holds true. That means debugging isn’t going to be too hard.

On the other hand, because Ruby is so expressive and because there are multiple ways to solve a problem, it can seem sometimes Rails is magic and that it’s not entirely clear where the source of your woes may be.

Now, that’s not a knock on Rails per se. It’s super SUPER easy to get a rails app up and running (I’d say 15 minutes roughly). There are lots of assumed pre configurations, which speeds up the development process. Django, in my experiences so far, on the other hand, requires a bunch of code upfront to set up. Depending on who you ask, some people want that control and flexibility, while others want something done quickly.

However, I do have to say, because there are so many assumed configurations in rails unless you’re familiar with the naming conventions, it may get tricky keeping track of how the conventions go. For instance, the naming convention for models is singular, but views and controllers are plural (Car vs Cars for example).

Conclusion

So how does one go about picking a framework? It seems to come down to comfort with the framework and the language. As you can see, both can be used to achieve the same goals, but there are pros and cons to both. Do you prefer a convention-over-configuration approach ala Rails, or want something with more control and explicit in Django?

Something also to consider are business needs and long term planning. Maybe you need to get something up and running quickly for an MVP. Perhaps Rails is the answer. What about something to do with machine-learning or fine-tuned customization? Django might be the answer.

Either way, consider your needs. You can’t go wrong with both.

Finally, I just want to say, with what’s going on with the Coronavirus, I hope all of you stay safe and healthy! Be mindful of those around you. be alert, not anxious and think about how we can get through this together, with your friends, family or community.

Published by Nicholas Moy

Software developer residing in New York.