|
Well, I want to start this off, by saying that I am not leaving Python or Perl behind for Ruby, but that is the order in which I learned these 3 languages. I learned Perl first and I used it strictly for about 3 years, then I learned Python and I have been using Python mainly since then and Perl when needed. Now since I am playing with Puppet, I figured I should go ahead and learn Ruby as well.
So far I am pretty impressed with Ruby as it reminds me of Python and Perl put together. Everything in Ruby is a Object just like it is in Python. Also you do not require a semicolon at the end of every line in Ruby like you do in Perl. You do not require a $ for a Scalar variable or a @ for an array or a % for a hash in Ruby, which you do require in Perl but not in Python. There are a lot more similarities then that, and I will post some of the commands that are similar and ones that are a bit different. Now this will not be a complete list of differences but enough so that you get the idea.
python print "hello world" #This will print hello world but with a New Line at the End ruby puts "hello world" #This will print hello world but with a New Line at the End perl print "hello world\n"; #This will print hello world but with a New Line at the End
python x = 8 #x is equal to 8 which is an integer ruby x = 8 #x is equal to 8 which is an integer perl $x = 8; #x is equal to 8 which is an integer
python type(x) #x is what type.... Integer, String, Class... etc ruby x.class #x is of what class.... FixNum, String, Class.. etc
python x, y, z = 1, 2, 3 #multiple assignments on one line ruby x, y, z = 1, 2, 3 #multiple assignments on one line perl ($x, $y, $z) = (1, 2, 3); #multiple assignments on one line
python se = "foil" #Assign a string to se ruby se = "foil" #Assign a string to se perl $se = "foil" #Assign a string to se
python se[0:4] #Access a slice of a string ruby se[0..4] #Access a slice of a string
|