Ruby
December 27th, 2006 . by brian.corralesSo I’ve been programming in CAKE PHP for about 6 months now and have really enjoyed the MVC framework. I’ve heard that Ruby on Rails is even slicker so I’m transitioning to Rails now. Last night I spend some time learning about Ruby. A friend of mine showed me Try Ruby! (in your browser) where you can learn to program Ruby directly from the browser! It was actually pretty fun and it starts you off with the very basic elements of programming. If any of you are not developers yet, but are interested in learning, this new Try Ruby! website is for you!
So far, I’m enjoying the syntax of Ruby. Most computer languages takes some getting used to. As I’ve learned Java and PHP, I”ve had to change my way of thinking to accomodate the language structure. Ruby, by contrast, accomodates the human programmer and the syntax of Ruby changes. For example, let’s say I wanted to print “Hello World!” five times in a browser, with a break after each line. In PHP, it would look like this:
for($i=0; $i<5; $i++) {
echo "Hello World!";
}
This says start with "i" equalling zero and print "Hello World to the console everytime. Add one to "i" everytime and continue the print until "i" is no longer less than 5.
Ruby, on the other hand, has much more intuitive syntax:
5.times { print “Hello World!“ }
This says exactly what is on the screen: Print “Hello World!” five times.
Not only is this an easier syntax to read and manage, it’s shorter and more concise. If anyone has some excellent online tutorials on Ruby and/or Rails, I’d be very grateful. So far, I’ve been reading Why’s Guide to Ruby. So far I’ve found it very helpful and an easy read.