Python vs Ruby - Which one you should learn and why?
Python and Ruby both are fast, powerful and also loved by programmers. But what sets the Ruby and Python scripting languages apart and which one you should learn?
At first glance, Python and Ruby appear to be very similar languages. Both are high-level, server-side scripting languages focusing on simplicity and prioritizing rapid development - getting things done fast, in fewer lines of code. Both are beautiful languages that, when written well, are intuitive and can read much like English. Standard libraries, persistence support, and feature-packed frameworks like Django and Rails are make them first choice for entrepreneurs and startups to rapidly whip up web apps and prototypes. Both are interpreted scripting languages, which means they don't require a compiler like Scala or C++ do. Compiled languages tend to run faster, though.
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.
Now, let's take a look at both language deeply -
Python was created in 1991 by Guido van Rossum, inspired by a multitude of languages - C/C++, java, Lisp, Perl and ICON. Python is all about efficiency and supporting calculation-heavy applications used in the fields of data and science. Along with its Django framework, It enables super fast development.
Unlike Ruby with its daring, 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. Its syntax is very simple, there is little to remember, and it is thus great for beginners.
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. Ruby, a language that's ideal for collaboration, speed, and businesses that want a programming language.
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. 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. 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. 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.
So, which language you should start learning?
Despite the noisy comparison 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 focus 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.
If you plan on sticking with building web applications, then check out Ruby and Rails. There's a very strong community built upon it and they are always on the bleeding edge.
If you are interested in building web applications but would like to learn a language that's used more generally, check out Python and Django. You'll get a diverse community and lots of influence and support from the various industries that it is used in.
Either way, you can't go wrong. Almost everything you learn in Python can be translated to Ruby and vice versa. They both have supportive communities behind them.