Ruby
Well, I got around to ordering a Ruby book (Programming Ruby). It got here about a week ago and I finished it off in about a day or so.
Now that I’ve dove right into Ruby, I’ve found it to be a very nice language indded. Amongst the other reputable interpreted languages available for wide-spread use (PHP, Perl, Python etc), I can say I really like Ruby the best. Before I purchased this book, I didn’t know all to much and I couldn’t really say if I would like it. I knew that A) It was gaining traction and B) it had a fabulous framework called Rails (which was pretty much acting like a catalyst for point A).
Syntactically, it was not very famarliar to what I’m used to (C-style). For a lot of programmers, this fact alone could be a turn-off. But I’ve tried a bit of Python, and I knew that something as simple as using {} instead of the keyword ‘end’ (for example) doesn’t really make a difference. But I was somewhat surprised to see some things that I always expected to see in any language, done quite differently. For example, there is no ‘for’ loop (perse, there is actually one but Ruby will internally replace it with what I show here). A for loop in PHP, for example, might use a variable that counts from 1-100 like so:
echo $i . “\n”;
In Ruby, you use methods and a very useful feature called blocks. Blocks allow the programmer to associate a block of code with a function call. The block of code can be called inside of the function. The same PHP code could be written in Ruby:
Since Ruby is a true OOP language, everything is an object. The literal number 1 is an object of type Fixnum (which is a subclass of Integer), and it has many useful methods that we can use to easily do what we want:
50.downto(40) { |x| puts x }
# Count up from 5 to 100 by 5’s (5, 10, 15 … 100)
5.step(100, 5) { |x| puts x }
# Just repeat 3 times (Ho Ho Ho)
3.times { print ‘Ho ‘ }
When I got to using Ruby, there were a bunch of little things that are very intuitive and elegant. If you have not already, give it a go and see if you like it! And I want to say that Rails does not make Ruby. If you don’t like Rails, then you don’t have to use it — another common misconception I hear about is people complaining they don’t like Rails and therefore won’t like Ruby. Ruby != Rails.