I installed Ruby the other day, and configured Rails. Now I’m fucking around with it trying to figure it all out. The language itself reminds me of Python but it has it’s own flow to it, that is quite unlike anything. For example, I love how methods returning boolean values end in question mark by convention. Loops are also very interesting, considering how everything is an object with built in methods. Here is a sample:
10.times { puts "Luke is awesome!" }
This snippet will tell you that I’m awesome exactly 10 times, thanks to the fact that all numbers are in fact objects with built-in iterator method times. Array iteration is even more funky:
[2, 4, 5, 10].each {|times| puts "Luke is #{times} more awesome than you"}
I don’t know about you but I think this is neat. And from what I have seen so far, things are quite consistent throughout the language. You essentially treat all the language elements and structures in the same way – as objects. Ruby does not seem to make exceptions for anything the way Java does with its’ primitives, and arrays…
Rails on the other hand, I still haven’t really figured out. All I know is that it creates five gazillion files in your project directory just to display a simple Helo World script. But there seems to be a method behind the madness – namely a clear separation of programming logic and presentation. It seems to be a little bit convoluted at first, but even after 5 minutes of messing around I can already feel the power lurking in Rails’ automated scripts.
I really like the idea of using RoR for that little pet project for my dad. And the fact that it comes with a built in server gives me an added benefit. I can just run the damn thing when I need it, and then shut it down. For a multi-user, production app I would use Apache but for a single user program WEBrick seems very appropriate.
Now I need some recommendations for good online tutorials and a good Ruby book. What I need is intermediate, hands-on stuff. I don’t need them to teach me how to program – I want to learn Ruby and Rails. Suggestions would be greatly appreciated.