Thursday 5 December 2013

Python vs Ruby Simple Code (1)

Playing with Python or Ruby is fun, compared to many other strongly type language like C++, C# or Java.

This is just compare the two language in very details as sort of note for myself.

Lemme start from the very basic one:
print
In Python, print is just a function, defined with default separator(' '), end-line(\n) and stream(sys.stdout). To print something to console,

In Python, I write

In Ruby, I write

Though Ruby is more flexible, I prefer the way python coding. Ruby is hiring two special character: $, and $\ to represent separator (sep= in Py) and append (end= in Py)

Ruby has puts which is being more widely used same as python's print (with sep param set as '\n'). However python seems simpler and more clear.

No comments :

Post a Comment