Our Product Design Process book is out now!

ORDER NOW

Ruby vs Python for web development (2020)

When you're thinking about your next web development project, you'll probably search for a framework that can provide every tool you need. This is where Ruby on Rails or Django show up. Both are frameworks that provide views, controllers and models to power your web application or instead, provide an API that offers endpoints to address your needs.

In this post, I will address Ruby vs Python for web development. More precisely Ruby on Rails vs Django frameworks, as both work for the same result, however, their methods and the way they're divided are different.

Why did we choose Ruby on Rails and Django? In one hand, Ruby on Rails gained a lot of attraction in the startup world for its edge on older tech, such as Java and .Net. In spite of its growth has slowed down, the desire to maintain those existing projects has kept its relevance in the web development market. On the other hand, Python has seen a huge boost in popularity in the corporate world because of its support for AI.

When comparing these two languages I'll take into account many factors such as popularity, learnability and project features. But let's start first with some context on these technologies.

What is Ruby ?

Ruby was created by Yukihiro Matsumoto and released in 1995. It got inspiration in part of its creator’s favorite languages, being Perl, Smalltalk, Eiffel, Ada and Lisp. Ruby is meant to be a language that balances functional programming with imperative programming and its main goal is to make code more natural. Ruby offers a powerful language that produces elegant and readable code while maintaining its expressiveness. It uses the power of blocks as a way to group statements (and then execute those statements when the block is called), the use of lambdas and functional programming as it’s main tools. Ruby nowadays is mostly used in web development in the form of this Ruby on Rails framework. Ruby on Rails has kept Ruby's popularity and jobs stable over the years.

What is Python ?

Python was created by Guido van Rossum and released in 1991. It came as a successor of the ABC language, a language intended to replace Basic and Pascal. Its philosophy is to enable code readability, by its notable use of white spaces. Python is one of the fastest-growing programming languages, as it has a wide range of use: from data science to machine learning and even academic use. Python is highly flexible due to its interpreters being available on the most popular operating systems and its wide list of libraries. Python becomes very strict when it comes to code indentation and white space. Although it can be annoying at times, it also results in an extremely readable and easy to learn language. AI is a huge computer science field nowadays, due to the advanced algorithms and the improvements to computing power, which leads to creating more accurate AI. That led to Pythons huge boost in popularity, mainly due to libraries like TensorFlow, Keras, Theano that enable its support in AI.

Why are they used in web development?

Ruby and Python are both solid languages to use in web development. Ruby offers Ruby on Rails, which uses a Model-View-Controller (MVC) architecture. The MVC architecture is a convention to separate logic. While Model stands for where the data is kept and processed, View is what shows the user his interface and displays the data and Controller is where the user requests that come from the View are handled and uses the Model data to send a response.

Python offers Django, which uses an MVC architecture with a small twist: a Model-View-Template (MVT) architecture. The MVT architecture is very similar to an MVC architecture but the framework takes care of routing. Template is to handle user interface completely. View is used to execute the business logic, interact with a model and is also where a template is rendered.

Ruby on Rails is headed by Basecamp, it was released in 2003 and revolutionised the market dominated by Javas(J2EE) and .Net, as it allowed a faster project development. Ruby on Rails got its boost in popularity due to the startup world, as it was used by companies such as Twitter, Airbnb, Github and Shopify. Ruby on Rails is still solid and heavily maintained by Basecamp and besides that it's still a good framework to build and produce web-products, it got out of fashion. Since Ruby on Rails developers are hard to find, startups and companies in general avoid starting new projects in this tech.

Django is an open-source project supported by Django Software Foundation and it was released in 2005. It gained popularity because of properties like being dynamic, accessible and it’s architecture being very similar to MVC. Django was used to build or remodel some of the most popular websites such as Instagram, Spotify, Youtube, BitBucket. Django can be used as an API together with a JavaScript front-end framework, using Django Rest framework.

Both languages offer excellent frameworks for web development. They are a clear improvement from the Java and .Net, since they speed up development, and offer clean design and abstractions so that you don't have to “reinvent the wheel”.

Their popularity and job market

For you to have an idea of their popularity, I will compare them based on StackOverflow questions, developers’ opinions and job market.

Number of question in StackOverflow of Ruby on Rails compared to Django

As for StackOverflow, we can see from the chart above, that Ruby on Rails overshadowed Django right in the beginning. When AI started to be used on web development, there's a notorious increase in Django's popularity. It surpassed Ruby on Rails in mid-2017 and all indicates that it will keep growing, while Ruby on Rails will continue to decline.

Another indicator of how a technology is growing or declining is their demand for developers in the market.

Number of posts in hiring trends of Rails compared to Django

As we can see from the chart above, Rails still leads in the job market, maybe because of the need to maintain the existing projects that were made when Rails was very popular.

Number of posts in hiring trends of Ruby compared to Python

But when we talk about Ruby vs Python, we can clearly see that Python kept the lead over Ruby. This is due to Python’s growth in AI and in other computer science areas, while Ruby maintains their focus mostly on web development.

From a job market perspective, you definitely need to ask yourself this question: if you are a developer, are you willing to switch areas or work on both? If you are willing to work on other areas then web development, Python is a better choice as it branches into AI and other computer science areas easily. If you want to work on web development, Ruby on Rails is still a solid career choice as there are still lots of projects that need to be maintained or started.

Ruby vs Python Comparison

Ruby and Python work to achieve the same goals in web development, but take different paths in the way. Ruby is designed to be infinitely flexible and empowering for programmers. Pythons primary goal is to make everything visible to the programmer. This sacrifices some of the elegance that Ruby has but gives Python a big advantage when it comes to learn how to code and to debug problems efficiently.

Their main difference lies in their communities and areas of use. Ruby is mostly used combined with Ruby on Rails, the equivalent to Django for Python. When comparing Ruby on Rails vs Django, Ruby wins in demand and stands almost as equal in popularity. As we branch out of web development into other computer science areas, Python beats Ruby by a large margin. Python has a strong presence in both data science and machine learning, the same cannot be said for Ruby. This can lead you topick Python for web development just because you could integrate various libraries that offer you other tools, with the ease of being in the same language.

How we’ve done it

So how am I familiar with both these languages and their respective frameworks? As an intern at Imaginary Cloud, I learned Ruby and Ruby on Rails as part of developing our website. This means that my experience with Ruby on Rails is mostly in maintaining an existing project of considerable size. Regarding Django, my experience comes from starting an internal project to enable all of us here in the office, to insert and vote on which games to buy for our PS4. While the backend was built with Django, its front-end was firstly built with Vue.js and in a second version, with React.
When comparing both projects, the PS4 project is way smaller in terms of complexity and size, nevertheless, it was developed from scratch contrarily to our website, which we've just maintained.

Are they easy to learn?

Ruby and Python, more precisely Django and Ruby on Rails, can be a rollercoaster of emotions. When you follow their tutorials, you start to understand their potential and powerful tools. Then, it ramps up to generic views or an auto-generation of a set model that handles and offers endpoints for specific operations over the data you provide. This can sound cool, but if something breaks, it makes you wonder what happened. When the magic stopped working, I had to read both documentation to fully understand what was behind it so I could be able to manipulate it and achieve success.

Is Ruby easy to learn ?

Learning Ruby was hard at first but as you grasp into his syntax and blocks, it becomes as natural as possible. When it comes to web development, Ruby on Rails is your Ruby web framework. I started to learn Rails with a tutorial on Pluralsight, an online learning website. I've then watched some Youtube tutorials on how to develop a simple blog using Ruby on Rails. As I mentioned previously, I used Ruby on Rails, on Imaginary Cloud website. Developing in an existing project vs a new one is quite different as both present new challenges. Applying new features to our website using Ruby on Rails was a challenging task at first, but when I began to better understand the project, the development got way easier.

Is Python easy to learn ?

Learning Python was easy as its syntax is quite similar to other programming languages taught in university. When it comes to web development, Django is your Python web framework. I started with the Django official tutorial to get an overall idea of its tools and structure. I found it very well-devised. Then, I used Django Rest framework to provide an API. It offered user models, request authentication and url routing. I have to say that I had a rough start, mainly due to the authentication and creation of an abstract user model to add custom fields to users. However, after that, I felt that development started to rush forward at full speed.

Which one is faster?

When thinking of performance, they have a few differences which are essentially runtime performance and compatibility to add more features. For runtime performance, in the same working conditions and project size, both frameworks offer similar times, but Rails is overall 0.7% faster. Although this time is often more impacted by request path, architecture and then framework, architecture is, in this case, the most impactful factor (due to the optimization of databases queries and structure).

Regarding compatibility Django gets ahead on Ruby on Rails. Since Django is written in Python, it's easier to implement and add new features like AI for data processing or specific Python libraries.

A wrap-up

In this post, we can say that both frameworks succeed in helping developers create web apps. However, Ruby doesn't really branch out of web development like Python.

If you just want to stick with web development Ruby is your best choice. But if you have in mind to add other features to your web application, like machine learning or other computer science areas, Python is the most suitable as it has libraries that support other fields.

We can also say that Python has a better longevity than Ruby because it can rely on other areas of support, not only web development.

I hope you find this post useful! Feel free to share it or to reach me with questions, comments, or any insights you may find useful!

Found this article useful? You might like these ones too!

At Imaginary Cloud, we simplify complex systems, delivering interfaces that users love. If you’ve enjoyed this article, you will certainly enjoy our newsletter, which may be subscribed below. Take this chance to also check our latest work and, if there is any project that you think we can help with, feel free to reach us. We look forward to hearing from you!