Ruby on Rails vs Django - The Back-end battle!

Updated on 7 May 2114 Min read

Django vs Rails development frameworks

Back-end systems are like the back bones of digital products. When you are building one, you must pay utmost attention to the back-end side of things. You don’t want to go wrong on this. This post discusses the two most popular choices for backend development — Django and Rails.

Topics covered in this post -

  • What is back-end development and why is it important?
  • Exploring Django vs Rails for back-end development
  • Why are they still relevant?
  • Some Key statistics
  • When to use & not use Django for back-end development?
  • When to use & not use Rails for back-end development?
  • A few popular companies that use Django and Rails
  • Differences in Django and Rails
  • What are people saying about Django & Rails?
  • Additional Resources & Wrap Up
  • FAQs

If you work in tech, you might have come across scenarios like the following -

A couple of folks come together to solve a problem and think about building a product. The thing with building products is that you need to have user validation. So, you start small. Once your product hits the market and if validated successfully, you are hit with one of the most common problems -

The problem is, we now have that validation but the product isn’t scalable. We outsourced the development so the backend isn’t what it should be it crashes and has lots of bugs.

And if you are a non-technical founder, it makes things overwhelmingly difficult for you under such circumstances.

So, why are we talking about this? Well, you see if you want to build a scalable product, you need to think about the back-end.

For those of you who are completely unaware about what a back-end is, here’s a quick crash course.

Whenever you are building a web application, mobile app etc. there are generally two things you need to think about in terms of development -

  • Front end development — This is what the users see
  • Back-end development — This is what the users don’t see

Think of an ATM. You insert your card, enter the password and boom! You get the cash. That’s the front-end side of things. But have you wondered how does this entire process happens within the machine? How does the ATM know you entered the correct password?

ATM: banking system architecture

Your password is actually sent to a server that processes your data. It examines whether the password is correct or incorrect. Next, it returns a success or failure message. This, in turn, decides whether you have access to your account or not.

A backend application is nothing but an interface to a database meant for reading the data models and presenting it to a user in a form that they understand.

The back-end side of things run on a server. Hence, it is also called as the server-side. Here’s a nice video explaining what exactly is back-end development —

So, when you are building a product, the server-side of things need to function well. If you don’t choose the right framework, your product could crash or offer a buggy user experience.

Let’s say your product is validated. For the initial MVP you might have quickly gone ahead with any framework. Because, there are costs attached to these things. As your product starts seeing an increase in daily active users (DAU), for example, think 20K+ users. If the back-end is not scalable, you will not be able to reach a larger user-base.

Therefore, you must think twice before choosing any back-end development framework. There are 30+ frameworks available.

Backend framework

However, for the purpose of this post, we will be sticking to Django and Rails.

Exploring Ruby on Rails v/s Django for back-end development

Django is an open-source, Python based web framework for developing web applications. You might wonder, what is a web framework? Wikipedia explains it the best,

A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs.

So what it basically does is provide you with generic functionalities to build a web app. It aims to reuse code, thus, helping developers cut down on the development time and cost. There are existing solutions available that ensure developers don’t need to write code from scratch.

Now, web frameworks also have two sides to them. Front-end and back-end. With Python based frameworks like Django, developers can select and combine different but complementary front end and back end elements depending on their goals. Based on the scope, you can focus on one or merge several elements.

Django is a batteries included framework.

The principle behind batteries-included is that the common functionality for building web applications should come with the framework instead of as separate libraries.

Here’s what Matt Makai, author of Full Stack Python says regarding this -

For example, authentication, URL routing, a template engine, an object-relational mapper (ORM), and database schema migrations are all included with the Django framework. Compare that included functionality to the Flask framework which requires a separate library such as Flask-Login to perform user authentication.

The batteries-included and extensibility philosophies are simply two different ways to tackle framework building. Neither philosophy is inherently better than the other one.

Fun fact: Django was named after the jazz guitarist Django Reinhardt.

Benefits of using Django for back-end development of your product/MVP in 2021

With Django you can launch your MVP within hours if you have the user flow, information architecture and UX of the product defined and clearly laid out. It’s that fast.

  • Django comes packed with some fantastic functionalities to launch your startup in record time. Content administration, site maps, RSS, user authentication, etc.
  • Define your models and the framework will automatically churn out a production ready admin interface. You could let authenticated users add, change and delete objects. The only step required is to register your model in the admin site.
  • A clean, elegant URL scheme is super important in a high-quality Web application. Django encourages beautiful URL design and doesn’t put any cruft in URLs, like .php or .asp. Read more about such benefits here.
  • When it comes to back-end systems, these need to be highly secured. The last thing you want in your app is mistakes like cross-site scripting, cross-site request forgery, clickjacking and SQL injection. Django is equipped with templates to help avoid these. Read more about security here.
  • Scalability is a must for your digital product if you want to increase the user base. Some of the most esteemed organizations across the globe are using Django to build scalable web applications.
  • Moreover, Django is very versatile in nature. Whether you need a CMS or a social network, Django can easily power the back-end side of your product.

Coming to Rails now.

Ruby on Rails follows a core principle — putting programmer happiness at the pedestal.

Rails, or Ruby on Rails, is an open-source framework based on the Ruby programming language. It was created by David Heinemeier Hansson in 2013. Using RoR, developers don’t have to rewrite every single piece of code in the process of web application development. It, thus, reduces the time spent on basic tasks.

Here’s an interesting excerpt from the Ruby on Rails doctrine -

Where Python might boast that there’s “one and preferably only one way to do something”, Ruby relished expressiveness and subtlety. Where Java championed forcefully protecting programmers from themselves, Ruby included a set of sharp knives in the welcome kit. Where Smalltalk drilled a purity of message passing, Ruby accumulated keywords and constructs with an almost gluttonous appetite.

Benefits of using RoR for back-end development of your product/MVP

  • Ruby on Rails is very startup-friendly. Teams are said to build apps 30%-40% faster than other frameworks. Because of readily available modules and plugins, developers don’t need to write code from scratch. That allows you to quickly launch your product.
  • Standardized file storage & programming conventions, allow developers to keep a project structured and readable. A huge time-saver!
  • RoR makes it easier for your team to modify code and make changes once your product has been launched. It is known for predictability and stability.
  • One can build highly secure web applications using RoR. As it is backed by an active community of developers, it works together to come up with solutions to latest vulnerabilities.
  • Rails operates on the DRY model. Don’t Repeat Yourself. It is basically a software development principle meaning —

“Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”.

  • By not writing the same information over and over again, the code is more maintainable, more extensible, and less buggy.
  • Convention over Configuration is another principle worth mentioning. It is focused on increasing developer productivity. According to its website, Rails is opinionated software. It makes the assumption that there is a “best” way to do things, and it’s designed to encourage that way — and in some cases to discourage alternatives. If you learn “The Rails Way” you’ll probably discover a tremendous increase in productivity. If you persist in bringing old habits from other languages to your Rails development, and trying to use patterns you learned elsewhere, you may have a less happy experience.

Are Django and Rails still relevant?

Of course. You need these frameworks because you don’t want to reinvent the wheel. The Founder of DelightChat, Sankalp Jonna, very aptly says why you should you Django and similar web frameworks.

If one has to do back end development from scratch here is what will happen. First you will realise that raw SQL queries would have to be written to manipulate the database and this stops scaling pretty quickly.

You might then resort to writing your own wrapper on top of the raw SQL queries so that you don’t end up repeating a lot of code. Great, but what about security? Anybody could easily run an SQL injection if you let users interface with raw queries.

So now you spend some more developer resources to take care of this problem, but before you can sit back and relax you will realise that you still haven’t handled security vulnerabilities like cross site scripting and clickjacking.

Let us assume that you have a very high will power and managed to handle this problem as well. How do you plan to expose your backend to your frontend (web/mobile app)?

You will do so using the HTTP protocol right? Well have you written a library to handle all the nuances involved with accepting a HTTP request in accordance with the protocol, authenticate the origin of the request, and then generate a response after running your business logic?

Of course not! Because can you even be considered a human if you write code to handle all of these things?

Key Statistics

There are approx 969,026 live websites using Ruby on Rails. Its also very widely used across industries.

Key Statistics Ruby on rails
Key Statistics Ruby on rails

However, according to the Stack Overflow Developer Survey, Ruby is no longer in the top 10 frameworks.

 Stack Overflow Developer Survey 2020 Ruby on rails
 Stack Overflow Developer Survey 2020 Ruby on rails

Coming Django usage, here is the bifurcation industry-wise and country-wise. In contrast to RoR, about 30,383 live websites run on Django.

Key Statistics Django
Key Statistics Django

Though Stack Overflow Survey has reported a decline in the usage of RoR in recent times, I believe it is still not the time to write off this wonderful framework.

When to use and not use Django for back-end application development (with a few examples)

I would recommend using Django when your application needs Machine Learning and Artificial Intelligence based core features and functionalities. If you have a strong Python development team, go for it.

Brands using Django
  • Use Django if you know the project will grow over time and will need features from the start like a database, migrations, cache, etc.
  • If you have a use case that’s in the Django wheelhouse — i.e. a CMS style CRUD application — you would have a hard time doing better than Django. If you’re not in that use case, think long and hard about it. Django is fantastic to use when writing with the framework, and a nightmare to work around when you need to do something it doesn’t easily support.
  • Python in general fails at some async and cpu-intensive tasks, while other languages (or even frameworks/libraries of Python) excel at it. Whatsapp for example excelled through its use of Erlang, and would not have worked well had it been build with Django.
  • Web applications like small CMS sites, large multi-language CMS sites, up to large custom-built applications (mostly API-based) for the likes of Mercedes-Benz and Deutsche Bahn can use Django. It scales beautifully (see the likes of Instagram, Disqus, Sentry, etc.), has a great security track record, sane deprecation schedules, and the core team keeps up with the times and new technologies but does so at a sane pace and without rushing things.
  • Django is the best choice when you need to move fast, deploy fast, and also make changes as you move ahead.
  • When scaling up/down quickly is a requirement, go for Django.
  • In case you required both API backend & web app within the same codebase.
  • When you need ORM support & don’t want to work with database queries directly.
  • If you web application is very huge and you can’t keep everything in a single codebase, don’t use Django. Break the app into micro-services with each being handled by a different team.
  • You want to build everything from scratch for a highly complex and custom/specific requirement.
  • If your app is basic and does not require a database, Django will not be useful.

When to use and not use Ruby on Rails for back-end application development (with a few examples)

When you need fast prototyping and are pressed for time, go for RoR in the back-end and React in the front-end. This stack is very popular with startups these days. It allows you to quickly test your idea and scale as the usage grows.

Also, when the requirements are not clearly defined and you expect a lot of changes/revisions/updates in your product, go for Ruby on Rails based back-end development.

Brands using RoR

RoR is an excellent choice for the following types of websites and applications —

  • Software as a Service products
  • Fintech and stock exchange web apps
  • eCommerce with advanced features/functionalities
  • Social networks
  • Informational portals.
  • Non-standard complex projects.
  • Dating websites and ad platforms.
  • Live streaming applications
  • Data analytics
When to use and not use Ruby on Rails for back-end application development in 2021

Don’t use RoR if -

  • If the tasks that your product/web application handles are too small and won’t grow, avoid using RoR. It will do more harm than good.
  • RoR is made for small teams and medium codebases. If your team has lots of developers and a massive codebase (think lots of controllers, models and/or lines of code), it will pull down the standard app IMHO. Ruby is not built for a team of 200+ programmers. That’s just too much for it. Read more here.
  • Performance can be an issue with RoR. For instance, if you are building something on the lines of Basecamp, rails might still work. But think about a product that 100 times bigger than it. Mostly B2C applications fall under this use case. Under these situations, your server costs can outgrow engineering costs.

Key Differences between Django and RoR

Key Differences between Django and RoR

What are people saying about Django and Ruby on Rails?

Ruby on Rails is not the young, exciting platform like it used to be. However, this doesn’t mean that it’s dead. — Uku Taht, Founder Plausible

As a developer for many years, I believe that RoR is way passed its prime.

Granted it’s one of the originals in the world of development and gave us years of rock-solid performance, I think it’s becoming outdated due to AI. Ruby on Rails just doesn’t have the functionality required by today’s applications that are more demanding, especially in regards to AI. — Raj Vardhman, CoFounder Go Remotely

When you have such progressive sites like Github and Shopify using it, it shows it is here to stay. Ruby on Rails is a very mature programme, and this stands in its favor. There are massive reasons that Ruby will continue to excel. — Sean Clancy, SEO Director at Edge

So far, I’ve loved Django. Everything is simple, easy to follow but sometimes you’d have to dig deep down to understand how Django do certain things and by then you’d have gained enough experience so you won’t stress about it.- Mujeeb, Full Stack Developer from Pakistan

What I liked about Django is that integrating other Python libs was easy, and some of them are way better than the Ruby equivalents. PIL is way better than any of the Ruby image manipulation libraries. Django also makes it easier to do GIS stuff out of the box. — A developer’s view about Django on news.ycombinator.com

Additional Resources

[@portabletext/react] Unknown block type "urllink", specify a component for it in the `components.types` prop
[@portabletext/react] Unknown block type "urllink", specify a component for it in the `components.types` prop

Wrap Up

Before using any question, be clear with your goals and needs of a project.

  • Are you building a time-sensitive product that needs to roll out quickly?
  • Will it have a large user base?
  • Will it have to use micro-services, machine learning, AI etc.?
  • Is stability important or experimentation

The answers to these questions are subjective. Sit with your team/co-founder to decide on many such factors like these before you decide to go ahead with any framework.

As far as Django and Ruby on Rails are concerned, they are here to stay in coming years and beyond.

author

Pratha Avashia

LinkedIn icon

FAQS

Stay curious, Questions?

What is back-end app development?

Click to show answer

A backend application is nothing but an interface to a database meant for reading the data models and presenting it to a user in a form that they understand.

What is Django?

Click to show answer

Django is an open-source, Python based web framework for developing web applications.

What is Ruby on Rails?

Click to show answer

Rails, or Ruby on Rails, is an open-source framework based on the Ruby programming language. It was created by David Heinemeier Hansson in 2013.

What is a web framework?

Click to show answer

A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs.

Which companies use Django?

Click to show answer

Instagram, Dropbox, Pinterest, Spotify, Washington Post and YouTube are some companies using Django.

Which companies use Rails?

Click to show answer

AirBnB, Shopify, Kickstarter, GitHub, Slideshare, Dribbble, & Groupon are some companies using Rails.

Are Django and Rails still relevant in 2021?

Click to show answer

Yes, these frameworks are still relevant in 2021. Startups and other companies can build highly scalable and secured back-end systems with these.

Why use these frameworks for back-end development?

Click to show answer

Besides being open-source (freely available), these frameworks allows companies to launch digital products in record time. Plus, these are highly scalable in nature to be able to handle many user requests per second.