CSC/ECE 517 Fall 2009/wiki1a 11 AS
Ruby vs Python
Definition of Ruby and Python
Ruby is a dynamic, reflective, general purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
Differences in their language features
The first thing to be noted in Ruby is that in Ruby everything is an object, whereas in Python you have the liberty to code without using objects.
// include example here
In ruby, the programmer can use blocks to extend the language for application specific control statements where as in Python you are supposed to use only the control statements provided by the language.
Differences in Programming Environment
What Ruby has and Python does not have?
Ruby has continuations, where as Python does not have it. One notable use of continuations in Ruby is for breakpoints in debuggers. However you can fake continuations in Python, and it seems that many of the use cases can instead be done with passing variables into .next() which you can do in Python 3.1. Hence, the use of continuations seems rather limited, and hard to understand, but it’s there in Ruby, and not in Python. So this is another plus for Ruby.
//examples must be included
What Python has and Ruby does not have?
1. It’s worth mentioning here that Python has some big features that Ruby doesn’t, like for example list comprehensions.
[foo(x) for x in alist if bar(x) != 'frotz']
This is definitely shorter than:
foo = [] for x in alist: if bar(x) != 'frotz': foo.append(x)
2.