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 - 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 - 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.