When faced with a choice between two programming languages, the easiest way to pick one or the other is to ask yourself what business goals you’re trying to achieve.
Delving into every single aspect of a given language to find a winner can be counterproductive, since certain languages offer similar functionalities despite their different philosophies.
This is certainly the case when comparing Python and Ruby. Both are general-purpose, high-level languages that allow developers to write concise and readable code to achieve similar, high-quality results when it comes to building web apps.
What makes them different, however, is their approach to solving problems, and their ways of doing so have grown over the years to encompass areas beyond web development.
In this article, we will give you a brief overview of the main characteristics of Python and Ruby to help you decide which one is a better fit for your next software project.
Table of contents
Ruby is an interpreted, general-purpose, open-source, 100% object-oriented programming language. It was designed and created in Japan by Yukihiro Matsumoto in 1995.
According to Matsumoto, the guiding ideas behind the creation of Ruby was to:
- design a programming language that he himself enjoyed coding in,
- make it fun to use for developers,
- limit the human effort and work associated with using it.
The language has been said to follow the principle of least astonishment, which means that it behaves in a way that minimizes confusion for an experienced user.
Ruby has plenty of web frameworks, with Ruby on Rails (sometimes called just “Rails”) being by far the most common one. In fact, the framework is so popular that it’s been credited with spreading awareness of Ruby itself.
The language’s plentiful third-party libraries are released as a “gems” and can be installed through a tool called RubyGems. The libraries are hosted on the public repository RubyGems.org and can also be found on GitHub.
Although Ruby is a general-purpose language, the prevalence of Ruby on Rails has led to the language being used predominantly for developing web applications.
Ruby can also be a great tool for startups as it allows you to rapidly build a prototype and test initial ideas.
II. What is Python? What is Python used for?
Just like Ruby, Python is a general-purpose, cross-platform programming language, created in the 1990s by Guido van Rossum.
Python is highly flexible and versatile, which means it’s a great solution for a variety of fields, including but not limited to:
The application of Python across different use cases has been possible in large part thanks to its wealth of pre-built libraries and frameworks that make it easier to implement and deploy working solutions.
Because it’s easy to learn, clear to read, and simple to write in, Python speeds up development without sacrificing reliability or scalability. Its accessible and intuitive syntax makes Python a great language to learn for beginners.
The language enjoys extensive support from a variety of tutorials and guides, as well as an ever-growing and dynamic community of enthusiasts. In 2014, it overtook Java as the most popular introductory teaching language at the top US universities.
Before we discuss what sets Python and Ruby apart, let’s first take a look at what they have in common. Both languages are:
- dynamically typed,
- used by top tech companies across many different sectors (for instance, Twitter, Shopify, and Airbnb use Ruby, while Spotify, Amazon, and Facebook use Python).
When it comes to popularity among programmers, Python beats Ruby hands down. Although there are plenty of programming language surveys out there and each offers slightly different results, Python is way ahead of Ruby in all the polls we’ve looked at.
In the 2019 Stack Overflow Developer Survey, one of the most comprehensive and authoritative studies of the developer community, Python ranked 4th while Ruby took the measly 12th spot. What is perhaps even more important, though, is the popularity trend.
According to GitHub’s Octoverse, Ruby’s popularity among the platform’s users has been gradually declining, with contributions decreasing by the year. The language went from being 5th in 2014 to being 10th four years later.
After being around for almost 30 years, Python has yet to show signs of stagnation in terms of development and user interest. A Stack Overflow prediction of Python’s upward popularity growth from 2017 has so far held true.
However, when it comes to web development, Python doesn’t come anywhere near the popularity of the Ruby on Rails framework. It boasts almost twice as many contributors on GitHub as Django, the most prevalent Python web framework that offers a similar feature set as RoR.
The availability of jobs that require knowledge of either Python or Ruby can also be a way of measuring their popularity. Even a cursory look at developer job boards, such as Stack Overflow, reveals that the demand for Python programmers by far surpasses the need for Ruby developers.
At the time of this writing, there are five times more vacancies for Pythonistas than for Ruby developers on these job search websites:
|LinkedIn (European Union)||14,000||88,500|
|Stack Overflow Jobs||250||1,150|
The results will naturally vary depending on the timing, but they can give you a general idea on how sought-after and valued the two languages are.
3. Ease of use
Ruby’s legendary beauty has sometimes been described as “magical,” since it empowers developers to come up with creative solutions. There is often more than one way of doing things in Ruby, all with the user’s convenience in mind.
However, this very fact not only allows for unconventional solutions, but also means that any errors can be difficult to detect and debug.
Python, on the other hand, is all about readability and visibility. Per The Zen of Python: “Explicit is better than implicit. Simple is better than complex.”
Although the principle might mean that Python code is more straightforward and doesn’t look as “elegant” as Ruby’s, it makes it easier to comb through, also through a previously unknown codebase. In the same fashion, Python projects tend to adhere to the PEP8 style guide, whereas the Ruby community is split between a few slightly different styles.
Ruby and Python are both considered to be highly expressive, meaning less code is required to achieve the program goal. This claim seems well supported by the statistical information from open-source projects as well as data from surveyed developers.
Both languages are extremely flexible, treating basic constructs such as classes and modules as simply different types of mutable objects. Meta-programming is the name of the game. With the power of monkey-patching, all kinds of coding possibilities open up.
Ruby may be considered even more flexible, since it allows you to replace arithmetic operators on base types. That being said, even on-the-fly code rewrites are possible in both languages, so the sky truly is the limit—just don’t expect the other developers to condone it.
Both Python and Ruby have supportive and dedicated communities behind them, and there are plenty of high-quality documentation and learning materials available online. Regardless of what kind of support a given developer might be looking for—from videos and podcasts to forums—both communities have produced excellent materials.
Here are some of the resources useful for Ruby and Ruby on Rails developers:
By virtue of having a wider range of use cases—from web applications to machine learning to science—Python has enjoyed a broader community support than Ruby. Its popularity makes it easy to find tips or even ready-made solutions to any problems you might be experiencing.
From beginner-level support to expert advice, groups and forums like these stand ready to help you out:
1. Advantages of Python
- easy to learn and use;
- has excellent readability and simple syntax that resembles the English language;
- enjoys a very stable and diverse community;
- has plenty of uses, including web development, academia, machine learning, data analysis, and scientific programming;
- is open source, meaning it’s free to use and distribute, also for commercial purposes;
- keeps on growing in popularity.
2. Disadvantages of Python
- although it’s one of the most expressive languages available, it can be considered inelegant and wasteful when compared to Ruby because of its explicit style;
- it’s not native to mobile environment;
- as an interpreted language, it can be slower than other languages.
1. Advantages of Ruby
- offers plenty of out-of-the-box features for web development,
- gives developers the freedom to apply creative solutions,
- just like Python, it’s open source.
2. Disadvantages of Ruby
- its flexibility means it can be difficult to debug,
- has few use cases other than web development,
- has a smaller support community than Python,
- it’s been declining in popularity.
Given everything we’ve covered so far, the answer to this question is fairly straightforward: unless you’re starting a new project that specifically requires you to use or know Ruby, you should go with Python. (And while you’re at it, make sure you start off with Python 3.)
Whatever you can do with Ruby, you can also do with Python. This rule doesn’t work the other way round, though. Python has a unique advantage in a number of areas such as machine learning, academia, statistics, or data analytics. It’s more widely applicable, which gives you more leeway when you decide to add more functionalities to your project.
However, when considering strictly web application development, Ruby can be the right choice given its excellent quality and time to market. You should be prepared to expand your tech stack beyond Ruby in case your needs change in the future, though.
Python is also quicker to learn. Its readability and simple syntax make it the perfect language to learn for beginners, or more experienced programmers looking to learn an additional skill. Readability also helps when you have a team developers who need to review each other's code, since it reduces the probability of misunderstanding.
1. Ruby in 2020 and beyond
In the past few years, there’s been a lot of talk about Ruby dying down. Looking up “is Ruby dead” returns countless blog posts that, year after year, announce that Ruby indeed is dead. To save you the trouble of going through them all, visiting isrubydead.com will offer a definite answer to this burning question.
Ruby’s position in rankings might have dropped, but it still tends to rank among the top 10 most popular programming languages. If this fact is anything to go by, big names such as Airbnb and GitHub continue using Ruby on Rails.
The language keeps developing, and each new released version comes with improvements that make it faster and cleaner. For instance, the eagerly awaited Rails 6 was released in August 2019, and it came packed with a lot of new features that are bound to make developers’ lives easier.
In short: despite the fact that its popularity has been slowly declining in recent years, Ruby remains a language with plenty to offer. If you’ve been using it in your projects and worry about it becoming obsolete, there’s no reason to panic just yet.
2. Python in 2020 and beyond
Python is one of the most popular programming languages in the world, and its rise in global rankings shows no signs of stopping.
The massive surge in the popularity of Python can’t be attributed to a single reason. The language’s clear syntax, versatility, availability of libraries, and supportive community have all played a part in this.
The growing interest in artificial intelligence is another factor that has fueled Python’s extraordinary rise. Due to its flexibility, comprehensiveness, and access to numerous scientific libraries—neatly described by our AI expert in this article—Python is a must-have for developers who create machine learning solutions.
According to Stack Overflow’s analysis of the growth of programming languages based on data from high-income countries, Python is the fastest-growing major language. In the last five years in particular, its expansion has been unprecedented.
As you can see, Ruby didn’t even make it to the ranking depicting the growth of major programming languages over time.
Although Python’s future was recently put into question when Guido van Rossum resigned from his title as the language’s Benevolent Dictator for Life, the community stepped in to figure out the governance model. Development did stagnate for a couple of months, but the new steering council quickly responded to the unprecedented challenge.
Given Python’s omnipresence and the pace of its development, its future looks very bright. If you’re a project manager looking for a versatile language, getting started with Python is a very safe bet.
Despite their many similarities, Python and Ruby also have a fair amount of differences, and familiarizing yourself with them should help you decide which language fits your next software project better.
If you’re only after web app development, in particular if you’re a startup, choosing Ruby might well meet your needs. However, if you’d like to keep your options open in terms of future scaling, or you’re an aspiring developer trying to pick the best language to learn in today’s competitive market, you can’t go wrong with Python.
While choosing your programming language, it may be a good idea for you to consider other criteria for both your personal and business development. Those may include:
- average salaries,
- company culture (surprisingly, it may have a significant impact on the programming language a given company chooses for its projects).
For Ruby and Python, those tend to be somewhat similar, but taking as much as possible into account will always make your decisions more informed.
Do you think we should consider other factors as well? Maybe we’ve missed some hidden strength or weakness of Ruby or Python you find relevant? Leave a comment, and we’ll surely get back to you.
And if you wish to learn more about Python and how it fares against other programming languages and frameworks, we encourage you to check out the following resources: