In times when computer programing is becoming more and more accessible due to the growing number of coding schools, online resources and bootcamps, this question seems to go viral - which computer language should I learn first or which language should I choose for my use case. This situation is no different for Ruby and Python.

The origins

Both Python and Ruby were created, when the world wide web was still in its infancy. Python was launched in 1991 by the Dutch programer Guido von Rossum. His ambition was to create a general-purpose language that would be user friendly and powerful. Why did he call his baby Python? Rossum was determined to call it like this as he was a great fan of Monty Python. As a matter of fact, this question is often a starter during job interviews for junior Python dev position.

Ruby was launched in 1993 by a Japanese Yukihiro „Matz” Matsamoto, but the official start date was two years later. Its goals are very similar to Python: user-focused, productive and fun. As Matz loved the practical utility of Perl, he wanted his own language to be “jewel-like”.

Similarities

Both Ruby and Python are used by web giants. Twitter, Airbnb, Groupon and Github were build with Ruby on Rails whereas platforms such as Pinterest, Instagram, National Geographic used Python.

For run-on-the-mill programers, Ruby and Python are very much alike, mainly due to visually similar syntax. Both are object-oriented, dynamically-typed server-side scripting languages - not only does that mean there is no need to wait for program to compile, but it also makes those languages easier and more fun to learn and use. Ruby and Python are also cross-platform languages. They work on unix, macos and windows, what is really convenient for programers working across many environments. Also, you can use either of them for any kind of project, as both are general-purpose languages. Whether Python or Ruby is the best choice for particular use case is a different question though.

The Power of Ruby - Strengths

Elegant, readable and elastic syntax

Indeed, its simplicity, elegance and pure fun of coding is attracting new generations of young developers. The years go by and Ruby is still in top 10 programing languages recommended to begin the programing journey with. Because of Ruby’s intuitive nature, it’s fairly easy to grasp the basics of its syntax and start writing the code that’s a pleasure to read.

Obviously, certain code style recommendations need to be followed in order to maintain its readability. Still, to achieve this goal we can benefit from Ruby’s flexibility and countless ways of achieving the same results.

If you are experienced programer, the way Ruby behaves should be even more intuitive for you. This is called the principle of least astonishment, which is the supreme goal of its design. Therefore, minimizing surprise leads to minimizing programers’ frustration.

Innovative community

The community centered around Ruby is undoubtedly a contributing factor to its popularity. As Ruby will turn 25 very soon, the amount of documentation and resources accumulated over this period is vast. Stackoverflow itself has over 300,000 questions related to Ruby and Rails. Conferences gathering its enthusiasts from all over the world are not unusual. Wroc_love.rb in Poland, Isle of Ruby in the UK or RubyKaigi in Japan, just to name a few.

There are over also 150,000 Ruby Gems - programs and libraries that have been downloaded over 35 millions of times at the time of writing. The new ones are being created on a regular basis, to provide wrappers around the recently released solutions, libraries and techniques. To keep up with new technologies, Ruby is constantly developing and each subsequent version tends to be faster and safer.

Ruby on Rails - web development framework

Ruby has been rocketed by its main framework called Ruby on Rails. These terms are often used interchangeably, as if there were no differences between them. For that record, Ruby is a general purpose programing language and Ruby on Rails, often called just Rails, is a server-side framework for building web applications.

Rails framework includes lots of ready-to-use solutions around web development what makes rapid development of this kind of software a breeze. This is one of the reasons why e-commerce giants, like Shopify, are fuelled by RoR. Sending e-mails, making payments, uploading attachments, launching live chat or in need of WYSIWYG? Rest assured that if not already covered by the framework itself there are Ruby Gems to meet all your needs.

Great testing tools

Ruby has some great testing tools. One of the most popular ones is BDD testing library RSpec, “designed to make Test-Driven Development a productive and enjoyable experience with features like rich command line program, extensible expectation language or built-in mocking framework” - the official Rspec introduction states.

In general, Test-Driven-Development is very encouraged in Ruby community and its main principle is very simple - developers make a list of requirements that their code must make for which test is written and then the codebase is modified for the test to pass.

RUBY WEAKNESSES

Not very diverse community

As far as Ruby’s community is active and supportive, it is focused mostly on web development from the very beginning. In contrary, Python’s community is spread over web, machine learning, robotics, data analysis and processing etc.

May be hard to debug

Quite a few things in Ruby can be done in a smart (and thus very expressive) way by using its elasticity, like metaprograming and implicitness. Programers often referred to it as “magic“. Although this seems like a great deal, this “magical” behavior of applications makes the code less verbose and harder to debug. Not very usable stack traces in Ruby do not help in this endeavour.

What is more, as Ruby is dynamically typed, some errors show up only at runtime and thus might be more difficult to identify. To counter this, programs written in Ruby require more testing.

Performance issues

Because Ruby is a scripting language, it will never be as fast as compiled languages by design. Another factor affecting Ruby’s performance is Global Interpreter Lock (GIL) - a mechanism preventing multiple threads to be executed concurrently. Even though GIL has many pros, like easy implementation or increasing the speed of single-threaded programs, it is slowing the process down for the multi-threaded ones. It seems that back in 2014 Matz’s aim was to remove GIL from Ruby. While it did not happen, during RubyKaigi conference in April 2019, Matz stated that the latest version of Ruby (Ruby 3) not only will implement better concurrency primates for Ruby, but the most of all, that Ruby 3 that is set to be released in 2020 will be three times faster than the current version.

Easy to learn, difficult to master

Due to readable syntax and flexibility, Ruby is considered an easy language to learn. Applying Ruby’s best practices like DRY (Don’t Repeat Yourself), KISS (Keep It Simple, Stupid) and YAGNI (You Aren’t Gonna Need It) effectively take significant effort to master, but in turn, we will get a code that is easy to read and maintain in the long run.

Backward-compatibility

Ruby is designed and is being kept backward-compatible, which means that in most cases there should be no extra steps involved in bumping language to the most recent version . However, it has some substantial drawbacks when it comes to ease of developing and optimising the language itself. There might be lots of features programmers rarely use but are being kept in the language core to make ruby backward compatible. It becomes even bigger nuisance if such features affect performance. Also, adding new, significant features many times involves introducing numerous workarounds, just not to introduce any breaking changes.

The Power of Python - Strengths

Very explicit

The Zen of Python is a collection of 19 guiding principles that influence the design of the Python programing language. One of the principles states that “there should be one-and preferably only one-obvious way to do it” - therefore resultant codebase becomes very comprehendable by majority of programmers familiar with Python. It may sound as programers’ expressiveness will be restricted, but Von Rossum has a reason for that:

Easy and simple to learn

Python is considered one of the easiest programing languages to learn due to its simple and readable syntax. If you have never coded before, Python is fairly easy to setup and a good place to start your programming journey.

Python’s simplicity derives from aforementioned Zen of Python. Simple is better than complex, sparse is better than densed, readability counts - these principles may tell you a lot about Python’s philosophy of making complicated things the easiest way possible.

Stable and diverse community

Python community is large and very diverse. Its focus spread not only on Web, but also on data science. What’s more, the emphasis is also put on diversity of its community in terms of cultural background. Python Software Foundation in its diversity statement states that diverse community makes Python stronger and more vibrant.

Python events are held on a regular basis, what may encourage a stability in its community. PyOhio in the US, PyCon in Australia or EuroPython in Switzerland, are just a few examples of those.

Lots of solutions around data science / data analysis

Python is considered the best programing language for data science. According to research, 48% of data scientists with less than 5 years of experience in their field pick Python as their prefered programing language. Valid reasons why scientists, researchers and analysts reach for Python may include but are not limited to: vast amount of data science libraries, data visualisation tools or packages aiming to develop deep learning algorithms.

Quick fact straight from Python’s success stories - in US only, over 36,000 weather forecasts are issued every day and the amount of data gathered in the process is vast. Collecting, analysing and reporting requires a lot of analytical horsepower, but it is all done by one programing language - Python.

Django

Django is the most popular Python’s framework used for building web applications. According to its developers, it’s “ridiculously fast, reassuringly secure and exceedingly scalable”. Again, Django’s goal derives from Python’s simplicity, so instead of reinventing the wheel, developers should take advantage of the code reusability and focus on developing new features. Framework itself provides lots of functionalities like authentication, authorization or admin panel out of the box.

PYTHON WEAKNESSES

Performance

Because Python is dynamically-typed and scripting language, it means that its performance is generally slower in comparison with compiled languages. Just like Ruby, Python is using Global Interpreter Lock that only allows single threads to be executed, which is slowing the whole process down. In fact, even though there are some differences in performance of Python and Ruby, those are not huge.

Community, that innovates slower

Python community is very diverse and is spread between many fields like Web, machine learning and data science. Lack of focus on one field might be one of the reasons why it reacts to technology evolution slower.

Backward-compatibility

There are two main versions of Python: 2.x and 3.x. Lack of backward compatibility in Python 3 may be a bit problematic. First of all, There are some unique properties or libraries available only on Python 2 and vice versa. For that reason programers or companies have their preferences for version they use. Some operating systems, like MAC OS still has Python 2 as the default version. What’s more, by the end of 2019, Python 2 will fall out of use, and switching to Python 3 will be highly recommended. Solution migration is not hassle free and it will require some preparation to implement.

Bottom line

Ruby and Python are languages aiming at facilitating developers’ lives through their simplicity and expressiveness. Both of them are very powerful and used by Web giants such as Google, Instagram or Twitter. Both are still highly recommended for beginners to learn. Also both can help you build projects of various complexity.

Currently Ruby is on the slight decline in popularity and Python is gaining lots of it due to ML/AI solutions it is used for. As Python is also very explicit language it is probably the best choice for new programmers to start with. Still, if you like to push boundaries of writing code effectively and love code that can be extremely readable, consider adding Ruby to your toolbox, especially if you are mostly interested in web development. Before making a choice, it might be worth to check out job postings in your area and maybe look for some mentorship. Last but not least, grasping both Ruby and Python should be fairly easy due to their similarities.