Python vs Ruby

Monday, March 31, 2014

Ruby is a dynamic, reflective, object-oriented general-purpose programming language which was designed and developed in the mid-1990s. Compared to Python, which treats code readability above everything else, the philosophy behind Ruby is that programmers should have the flexibility, freedom and power to write concise and compact code.

The most important difference between Python and Ruby is that the philosophy of Python requires almost everything explicitly defined by a programmer while Ruby allows the programmer to write code with implicit behaviour inherited from other components. For example, in Ruby, the self in instance methods is implicitly defined while Python requires self to be the first argument declared into an instance method.


In the example code above, the class Hello contains two instance methods hello() and call_hello(). Notice that Ruby's definition of call_hello() simply calls the hello() method without referring to self.hello() like Python's definition does.

source: http://www.pythoncentral.io/

No comments:

Post a Comment