Today we are going to compare Rails to Django! Basically, these are two well-made web frameworks for web development that have a lot of similarities from the programming perspective. Rails comes from Ruby and Django comes from Python. They are both dynamically-typed, object-oriented languages. But the performance of Rails and Django depends on projects where they are implemented. You can say that they are like twins in some measure: the only difference is the language under the hood, their philosophies, and the ecosystem.
Let's take a look at a history to understand them better!
History of Ruby on Rails
This web framework was originally released 10 years ago in 2008. Ruby on Rails quickly gained attention and became more popular than Django. Ruby on Rails powers a lot of popular websites, like Fiverr, GitHub, Basecamp, Airbnb. As of winter 2017, the number of contributors on GitHub surpassed 3 300.
Ruby on Rails (just like Django) comes with a basic toolkit that might be used by a developer to build a database-driven app.
The main principle of Rails is “convention over configuration”: you don't have to write as much code as you do in Django. Ruby on Rails is available under an MIT license
History of Django
Django was released in 2005. This Python-based web framework was originally created in order to speed up a news sites development. Today it is an evolved web framework for general purposes. Some apps built on Django may be quite familiar to you, like Pinterest, Instagram or Bitbucket.
This web framework provides built-in ORM, Authentication, Admin UI, Session management and other juicy tools. It is quite easy to write and read the code in Django. This framework is available under a 3 clause BSD license.
Rails and Django on the world scene
As we can see, at least in the past year Django and Rails are running nose to nose.
As we can see, Ruby is in the top 10, while Django holds only the 12th position. There are more than 200 000 websites built with Rails than with Django. The total number of websites added over the past month:
Ruby on Rails: 6 304;
Django: 1 228;
The Django's number of added websites is only 19.48% of the number of sites based on Rails.
Websites dropped over the past month:
Ruby on Rails: 4 062;
A quite similar picture: the number of dropped websites based on Django is 21.91% of the Rails' number.
If we focus on the tendencies inside the web frameworks ecosystem, we'll see that in case of Rails, there are 64,44% of websites are dropped on the monthly basis, while the share of dropped websites that are built on Django is 72,48% on the same basis.
Well, despite the fact that Rails has a 3.3% market share, while Django holds only 0.68%, the picture is quite similar.
Similarities and Differences
The level of performance is quite similar. If you compare Bitbucket (which is based on Django) and Github (which is based on Rails), you'll notice that they are equally fast. If you want to build a website that will be work fast enough, there is no big difference between Django or Rails.
The architecture of Rails and Django is based on a well-structured MVC model. Due to this fact, your application will have basic divisions between conventional layers: defined models, controllers, and routes. Things can be implemented differently in Django and Rails, but we are talking only about the scheme and there is nothing to worry about.
Django is a great web framework, with which you can build complex database-driven web applications and websites in a shorter time. Meanwhile, Ruby on Rails is your boy, if you want to build modern database-backed web apps. Rails has a little bit better usability, though.
The Django way:
It's easy to write and read your code;
Explicit is better than implicit;
DRY (Don't Repeat Yourself)
The Rails way:
Codes are shorter and cleaner;
Convention over configuration;
Django is quicker to install. It could take a few seconds and requires a created virtualenv and then just to run a pip install command. It takes a little bit more time to install Rails. First, you have to install bundle and gem and then run the gem install rails command.
There are plenty of third-party libraries and a lot of platforms are able for free so you can learn about them. We would recommend you Django Packages, and it is really hard to find a better one if you are looking for a Django Apps. Unfortunately, Rails is not supported with such a hidden treasure.
It's steep for Rails, because you have to pick up a lot of independent concepts, so it's highly recommended for seasoned programmers. Meanwhile, you can learn Django a bit faster, due to the better readability of the code, so it will be a good choice for beginners.
Community and support
You can interact with Django's community through mailing lists, blog posts, stackoverflow. Rails' community is better stated in conferences, open source libraries, and books.
From the point of view of the programming language
From a user point of view, the app is identical no matter how it's built and what framework has been used. If Instagram has been developed with RoR, not with Django, it would be the same Instagram we like and use. The difference is under the cover.
The main difference contains in the programming languages, philosophy, and approach. Python is more about obviousness, while Ruby is about flexibility and freedom.
Notable open-source projects
Bootcamp. It is a simple and enterprise network with a simple feed app on the front page. You can take Bootcamp as an enterprise Twitter-like microblog;
Woid. Django based web crawler that sorts top stories from a website you like to read. It is a good example of a fairly simple Django open-source project that shows how to do simple web-crawling;
Parsifal. This tool performs a systematic literature review that requires a huge amount of time from the researcher;
Bloodhound. Another web-crawler, which purpose is tracking and indexing price movements on retail stores on a daily basis.
Ruby on Rails:
Discourse. A simple platform for a simple communication, which works like a forum and mailing list in common;
Spree Commerce. With this open-source platform, you can build online storefronts. Some well-known brands, like Lavazza, for example, uses this platform;
Refinery CMS. This Ruby on Rails based content management system is a classy out-of-the-box solution. It is available for free and supported by a large community;
Fat-Free CRM. This is a customer relationship management platform that provides automate sales processes. It handles managing contacts, lead tracking, customer databases and quotes.
Why should I choose Django?
You can go with Django if your team prefers Django philosophy, works with Python and believes that documentation is the best friend. It is also a right decision if you have to work with Python libraries, like machine learning apps, etc.
Advantages of Django
As a developer, you have more control when choosing configuration options and layout;
It is concise and transparent;
Many updates are not that painful and frequent as in the case of RoR;
Python resembles the English syntax;
It is really stronger and useful in such areas as analytics, scientific programming, data manipulation, system administration.
Why should I choose Rails?
If a wide range of plugins is ok for you – that's will be a bonus! Ruby on Rails is a framework that does the work for you, and its web-oriented community will give you a solid backup.
Benefits of using Ruby on Rails
The main goal of the philosophy is CoC (convention over configuration). In other words, Ruby on Rails has a well-made structured layout with defaults. You can easily get up and run it;
If you prefer pattern-matching characters in syntax, then Rails is for you. Differing characters are used as an analog to keywords;
Rails provides a good adaptation and speed;
Large community both offline and online.
The bottom line
You can't go wrong by choosing either Rails or Django. As I always suggest: try both of them and you'll get, with which one you're more comfortable with. Rails offers you automatic imports, controller instance variables are passing to the view in automatic mode, and it should be noted that the writing test is spectacularly convenient. On the other hand, with Django, you always know what exactly your code is doing, even if you barely know it. They both are outstanding in terms of web development. It doesn't matter, whether you decide to pick up Django or Rails, you'll have everything you need for developing clean, modularized code and save a lot of time on common stuff.