[Infographic] Python vs Ruby

Posted by UpGuard

Python vs. Ruby

Python and Ruby are two of the best examples of the new generation of high-level languages which focus on simplicity and giving the programmer the ability to get things done fast, rather than syntax correctness and strict hierarchy (insert cough that sounds like “Java!” here).

First the similarities. Both are high-level, object-oriented languages. Both provide an interactive shell, standard libraries, and persistence support. They are also both excellent for web development, more so when you take advantage of each language’s purpose-built web frameworks – Django for Python and Rails for Ruby. That said, Ruby on Rails is somewhat more popular as a web development tool than Django-Python. Python is favored more in the academic and scientific arenas.

But beyond that they also have some major differences. They also, surprisingly, have their passionate adherents and equally passionate detractors, which has resulted in more than one flame war that’s degenerated into insults and ad hominem attacks, and even into Godwin’s law. None of that here; we’ll delve into objective assessments and stick to what each language can or cannot do.


Ruby was created in 1995 by the renowned Yukihiro “Matz” Matsumoto and was influenced by C, Perl, Java and C++. It is unabashedly object-oriented; in Ruby everything is an object. Some famous sites built using Ruby (on Rails) are Twitter, Hulu and Groupon.

From the very beginning, Ruby’s ethos has always been expressiveness, power and elegance. Its dedicated followers love it for its ‘principle of least astonishment’ - the belief that a language’s code should always cause as little confusion as possible for the developer. See this article for some excellent examples of how Ruby’s elegance and expressiveness stacks up against Java’s old-school way of doing things.

This guiding principle naturally leads to Ruby’s inheritance of the Perl philosophy of having more than one way to do the same thing. This is the main difference between it and Python, as we’ll see later. This in turn means that a method can have multiple names, and this could lead to confusion for newbies.


7 Ways to Hack Ruby on Rails

An often-touted superior feature of Ruby’s is its use of blocks. A block is a first-class object treated as a unit within the program. This ability makes the language very powerful, especially when combined with its other forte – functional programming and use of lambdas. Also, Ruby takes the OOP concept to its limit. In Ruby absolutely everything is an object; even global variables are actually represented within the ObjectSpace object. Classes and modules are themselves objects, and functions and operators are methods of objects.

A quick list of features that work well in Ruby but not Python is listed below, and described in more detail here.

  • Use of blocks
  • Functional programming
  • Fragmentatio
  • Hashable/ unhashable types
  • Mutable strings

Ruby or PHP, which is better?


Python was created in 1991 by Guido van Rossum, inspired by a multitude of languages – C/C++, java, Lisp, Perl and ICON. Some famous Python-built websites are Google and Youtube.

Unlike Ruby with its daring, somewhat adventurous nature, Python is somewhat conservative. Python abhors Ruby’s ‘many ways of doing something’ school of thought; instead it has always stressed that there is only one best way to do something, and the language should do it that way. This results in a language strict on layout and indentation and even the amount of whitespace to use (!), which of course feels stifling to Ruby proponents. However, this regimented philosophy results in Python being supremely readable and easy to learn – in fact a good number of schools and colleges use Python as a teaching aid. Its syntax is very simple, there is little to remember, and it is thus great for beginners.

Python also boasts extensive libraries and an OO nature, though this is not as ‘pure’ as Ruby’s and is similar to object orientation in C++. Some more features in which Python is superior to Ruby are listed below and also expanded on here.

  • Better namespace handling and use of modules
  • Central use of iterators
  • Internal functions
  • A richer set of data structures


Despite the noisy arguments from both languages’ camps, it is impossible to say whether one language is overall ‘better’ than the other. It’s clear that each has some areas it is better suited to, because of its features and support from other users in the same area. For Ruby this is web development via the Rails framework, and for Python it is scientific and academic programming. And each has some features or capabilities that the other does not have or does not do well.

The two languages also espouse radically different philosophies. Ruby focusses on giving developers the freedom to do whatever they want and staying out of their way. Python insists on ease of learning and use by zeroing on only on the one right way to do something. This produces an interesting culture split between the camps – Python developers are somewhat conservative and value stability over change, developments and new features are added slowly. Ruby adherents seem to thrive on change and freedom. For instance the Rails framework is constantly changing, and in fact many of the changes and new features in Python are first tested in Ruby. Read more about these different mindsets here.

Get Started With UpGuard


Python vs. Ruby



Topics: ruby

UpGuard customers