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 -
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 -
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?
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.
However, for the purpose of this post, we will be sticking to Django and Rails.
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,
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.
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.
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.
“Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”.
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 in 2021.
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 in 2021?
There are approx 969,026 live websites using Ruby on Rails. Its also very widely used across industries.
However, according to the Stack Overflow Developer Survey 2020, Ruby is no longer in the top 10 frameworks.
Coming Django usage, here is the bifurcation industry-wise and country-wise. In contrast to RoR, about 30,383 live websites run on 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.
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.
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.
RoR is an excellent choice for the following types of websites and applications —
Don’t use RoR if -
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
Before using any question, be clear with your goals and needs of a project.
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 2021 and beyond.