When it comes to Object-Oriented Programming (OOP), two languages stand out from the pack in terms of maturity, community and worldwide use, namely Ruby and Python. And since a large portion of programming languages are used in conjunction with web development, we have to discuss their respective web frameworks: Ruby on Rails and Django.
But which framework is best suited for you in 2021?
Main similarities between Django and Ruby on RailsFirst of all, both of these are web frameworks and should not be confused with their respective languages. 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 – basically any application that is designed to be used over the web and as such adheres to web protocols and standard practices.Both of their underlying languages are OOP languages, meaning that they are used to create objects that pass messages since everything is an object in OOP. Note: If you’re unfamiliar with what OOP is, in short, the whole idea behind OOP is passing messages and that every object doesn’t care who the message receiver is or who the message sender is. This means that objects can change behavior depending on what messages they work with. That is the whole basis of polymorphism.
Plenty of libraries for Ruby on Rails and DjangoThese external libraries come in the form of “gems” in Rails and “packages” in Django. The installing procedure and syntax is extremely similar.For example, if you want to add user authentication in your Rails application, all you need to do is:
- pip3 install Flask-Authorization in your terminal
- Or add it to your requirements file and execute that
Language version management for Django and RailsAnother cool similarity is environment control… well, sort off.Working on multiple projects at once can be difficult regardless if they are in Django or Rails since dependencies often change depending on the project. One notable dependency is the language version.It is true that Ruby and Python are singular languages, but each one in part hosts multiple versions of themselves. And sometimes switching projects without switching language versions in your system environment can break your work – unless you are using Docker.To solve this problem, the ruby community uses version managers, the most popular two choices being
rbenv, the latter being the more recommended one.For python,
pyenvis the preferred tool of choice.
Other noteworthy similarities
- Open sourced
- Dynamic type
- Maturity – both languages are over two decades old and both web frameworks are over 15 years old
- Late binding
- Syntactic sugar
- Highly extensible
- Human-friendly syntax
- Human-friendly syntax
- General purpose
- Free to use
Major differences between Ruby on Rails and Django Framework
Underlying languageWe already touched upon the main difference between the two frameworks as being the underlying languages.Short history lesson: the initial idea behind Python came about in the late 80’s from Guido van Rossum in the Netherlands. The intent was to have a language capable of exception handling and interfacing with the Amoeba operating system.On the other side, Ruby was birthed in the mid-90s in Japan by Yukihiro “Matz” Matsumoto, who wanted something more serious than Pearl and “more object oriented” than Python. In 1999, Matz was quoted as saying, “I knew Python then. But I didn’t like it, because I didn’t think it was a true object-oriented language – OO features appeared to be an add-on to the language.”Fast forward to 2021 and the current stable versions available for both languages are Ruby 3.0.0 and Python 3.9.2The differences in numbering come about from how many major and minor releases both language developers have made since both languages took decades to arrive at their current iteration.
User interfaceThere aren’t many differences when it comes to user interface. I mean, there are differences between Django and Ruby on Rails, but more of a flavor difference rather than a type difference.Both are very heavily adapted to handle all free market requirements for 21st century web development. When it comes to web frameworks, chances are if it’s something you cannot do with Django or Ruby on Rails, it’s not really something that can be done.So it’s more a question of taste which you should choose when it comes to their respective interface. You should experiment with both to get a feel for them and make a decision afterwards.
PerformanceBack in the 80s and 90s, developer time was cheap and processor time was expensive. Every problem encountered was in similar parts an issue of hardware as much as software.Fast forward to the present and the situation is the inverse. With such high human resource costs and how hard it is to attract new developers, the developer time has become significantly more expensive as opposed to the new generation style of hardware available that provides super fast run times, computational power, and hosting solutions.However, just because computers and servers nowadays can “handle it”, that doesn’t mean that we should be sloppy. As such, when it comes to speed, both frameworks and underlying languages perform very well, taking into account their scope of use. But if you must be excessively picky, it was observed that Rails is slightly faster, even if by a very small margin.
BootstrappingHow many people actually enjoy setting up environments? Well, if you go by the ever-increasing popularity of containers – and I’m speaking about Docker here – then apparently not a lot.How fast – in a download-to-develop sense – are you really with either platform?Well, it is a matter of luck to be brutally honest. If everything goes smoothly, both are very easy to install and set up by following their respective installation guides. And where Rails will have you installing gems, Django will have you installing packages.But much like how setting up Django on Windows or MacOs might be different than on Linux, so can differences appear between both frameworks on the same machine. It depends on the machine and on the requirements – aka dependencies – you need for your specific task. Do you want a certain type of database setup? Is it an Sql database or a NoSql?And this goes further down depending on which specific database you want. Do you need to perform simple straightforward user interactions on your app or do you maybe require handling big data sets, and even analyzing and interpreting them? If so, you will need to research beforehand what libraries are currently available for both frameworks. And depending on what libraries there are and what dependencies each of them has, then initial installation and configuration can quickly become burdensome. So you cannot really answer the question of which is faster to set up. But it’s fair to say both can be equally as simple or as frustrating to get started with, depending on your particular circumstances and luck.
Availability of documentation and user referencesBoth frameworks have very large communities behind them and as such there is a plethora of user references, documented user experience, and also community driven guides and guidelines – all to facilitate ease of use and ease of understanding. On the official side, since both underlying languages and frameworks are old enough to be considered mature (through and through), it comes as no surprise that both offer extensible, well maintained, and up-to-date documentation.This documentation coverage ranges from installation and download, which are very generic issues, to edge case scenarios.It is safe to say that no matter what framework you choose, you will never be in the dark when it comes to functionality, expected results, edge cases, gotchas, and the like. Whether with Django or with Rails, you will never feel alone in your development career.
Flexibility of usePython is the darling of the academic world when it comes to data science, and that makes sense when you think of the relationship between Python and the graphics card industry.So if your webapp is designed to center around big data sets, machine learning, and all that crowdfunding terminology, then you should go with Django so as to be able to leverage all the existing libraries that already tackle those issues.If you focus on the custom things you need to apply your business domain knowledge, how you manipulate data from your database, and all the cool tricks you need to distinguish your app from your competitors, then you should go the Rails route. Its developer-centered philosophy and flexibility of use – with metaprogramming, DSLs, and syntactic sugar – gives your engineers significant freedom and fun when developing. Caution though: Rails gives you enough rope to either have fun or really hurt yourself.
Learning curvePython is fairly easy to pick up and learn, but difficult to master – as with all things worthwhile – and as such Django follows behind with the same curvature. It is a great first language and a great first framework.It also works great if you decide to switch fields and pick it up after years of, let’s say, Java or PHP.Rails has a whole philosophy behind it. If you are in tune with it, it is very easy to pick it up – maybe even easier than Django. The caveat is that you must first understand the philosophy behind it. Things like “Convention over Configuration” and “DRY” (Don’t Repeat Yourself) are cornerstones of “The Rails Way”, to name a few.This underlying philosophy with its guiding principles and specific way of doing things takes time to rummage around and adopt. This is also why plenty of people recommend Rails to more seasoned developers, people who know the pain of programming and the realities of the industry, and as such are equipped with the necessary background or experience to very easily adopt the Rails Way.
What should you pick?If this were a perfect world and time was of no constraint, then the obvious choice would be to pick both.You will grow way faster and stronger as a developer if you experiment in a production environment with more than just one language or framework.But if you are like me, and everyone else on Earth for that matter, and lack the time to indulge in everything that is new and interesting, then you will have to make your choice based on the realities you live in. Some things to help guide your choice may include:Personal reasons:
- Number of jobs available
- Average industry salary in your area
- Growth opportunities in your area
- Disposition for travel or lack thereof
- Availability of mentors
- Business application – what type of application is it?
- Availability of libraries and prior research
- Availability of human resource – how scarce are developers?
- Can it be done with that technology?
- Should it be done with that technology or are there better alternatives?
Successful business apps powered by Django
- The Washington Post
Successful business apps powered by Ruby on Rails