Python and Ruby are two of the most popular new generation programming languages which are dynamically typed, scripting languages with strong support for objected oriented programming architecture and whose implementation is quite different from that of the reigning programming languages such as Java and C. Neither of the new languages have strict syntax or hierarchy and instead focus on helping developers “do things fast” instead worrying about missed semi-colon or closing curly brace. Then both Python and Ruby have interactive shell and collections of libraries which make the respective languages more powerful. They are also widely used for web development with the help of their respective frameworks – Django (Python) and Ruby on Rails. So, while Python and Ruby are in many ways, similar, they are also rival languages and have some key differences. But first let us go through a brief overview of the two languages.
Ruby was designed by Japanese Computer Scientist Yukihiro “Matz” Matsumoto and released in 1995 as a dynamic, reflective, objected oriented general purpose programming language. Ruby’s philosophy revolves around the idea that a programming language it should be user (developer)-friendly rather than being created to run best on the machine. In other words, the programming language should not be such that while programming the focus should not on what the machine can do, rather it should let the programmer work out the best way to accomplish a task. Ruby’s Principle of Least Astonishment (POLA) reflects the ethos that existing code should cause least confusion to developers because of the elegant manner in which it is written.
Ruby is strongly object-oriented, every value including classes, instances of types and even methods are treated as objects. Methods defined at the top level scope become members of the Object class which is the ancestor of all other classes and are as such visible in all scopes, serving as global procedure. Ruby has been described as a multi-paradigm programming language as it supports both procedural programming and functional programming. Ruby’s syntax is somewhat similar to that of Perl and Python but with strong influence of its object-oriented architecture. Ruby also has its community of developers who follow its developments closely and help develop “gems”, Ruby’s term for libraries and in few instances, applications and IDE. Ruby is open-source and However, Ruby’s biggest strength is the framework Ruby on Rails which popularized the language immensely after its release in 2005 and has been used to develop popular websites like Twitter and Groupon.
Python is a general-purpose high-level programming language which is also defined as multi-paradigm programming language for its support for object-oriented programming, structured programming, functional programming as well as aspect-oriented programming among others. It was first implemented in 1989 by Guido Van Rossum in 1989 but gained huge popularity in the 2000s. In contrast to Perl and Ruby’s philosophy of “many ways of doing a thing”, Python’s motto ” “There should be one — and preferably only one — obvious way to do it.” is a direct challenge to Perl as well as Ruby and factored majorly in the competition between the two new generation languages. However, what sets Python apart is the strict layout of the language such that even indentation a whitespace are central to the code structure. But Python code is easy to read, almost making it look like pseudo-code, so it is easy to learn for beginners and offers the best readability to experienced programmers. Python also has a wide collection of libraries, the official repository of Python libraries (Python Package Index) offers functionalities as diverse as graphical user interfaces, multimedia, web frameworks, databases connectivity, networking and communication, system administration, test frameworks, automation, text and image processing, scientific computing to name a few. Also Python is compatible with most number of platforms and is bundled with most Linux distributions.
Popularity of Python Over Ruby
While both Python and Ruby had been around for some time, Ruby gained popularity with the arrival of the Ruby on Rails framework in 2005. By the time, Python had already established itself as a programmer-friendly and powerful language and created a niche for itself. Although, even now Ruby on Rails remains a more popular framework over Python’s Django, it also means Ruby has remained restricted to web development framework while Python has diversified and emerged as the preferred language in several other areas. Python has also garnered a larger community of users loyal to it and a large repository of library modules and documentation. While Ruby too has some very dedicated programmers championing for it, the fact remains that Python still manages to have larger community of Python collaborators.
One of the key reasons of Python’s popularity is its language architecture which makes it easier to both write and read code. Since it is easy to learn, a lot of beginners are adopting it and schools and colleges are including it as part of their syllabus. As readability of code is a strong merit of Python, experienced programmers are adopting it too to cut down time in maintaining and upgrading code. Further, Python runs well in most platforms and is included as a standard component with most Linux distributions, FreeBSD, NetBSD, OpenBSD, OS X and AmigaOS4 and is fully compatible with other OSes including Windows which makes accessibility of the language to the programmers easy and encourages beginners to explore it. From a simple web search it seems apparent that Python is emerging as the more popular language from among the two new generation programming languages.
According to Wikipedia, Python has remained in the top eight most popular languages since 2008 in TIOBE Programming Community Index indicating that its popularity has been very consistent. In TIOBE Index for July 2015, Python occupies the 5th position while Ruby has been pushed down to the 15th. It would thus be safe to conclude that Python is much more popular than Ruby.