Learning Ruby: What’s Worked So far
I’ve been speculating about documenting my ‘quest’ so to speak on learning Ruby on Rails. What’s drawn me to this, over PHP5 which to this point I’m completely comfortable with, is that RoR is said to be the best for developers, and you can do things that would take PHP thousands of lines in 60! That’s probably not always the case, but there’s a screen cast (warning: that links right to the movie/.mov file) of a guy writing a blog system in 58 lines.
The progress I’ve made so far hasn’t been that great, but with previous programming experience it’s easier than I would imagine for some. Some of the things I’ve gathered so far have been pretty usefull, and I’ll document them as I go along, as well as some code examples that help me get the syntax. Some of the links so far:
- Ruby on Rails.org Screen casts
- SitePoint’s indepth Beginner’s Guide
- The Official Site? Maybe, but its good.
- InstantRails for localhost development
Some basic code examples now, that as someone who already knows PHP, found greatly helpful.
# Comment, obviously
# The "Hello World" thing is always a first step
puts "Yo, world, what up?"
# or...
print "another way, slghtly different probably"
# notice the lack of semi colons...
That’s pretty much the first thing anyone learns with anything, whether it be PHP’s echo(), JavaScript’s document.write, etc… Getting into some variables is pretty easy too.
# variable time
text = "variables pretty similar to javascript..."
puts text
# one of my favourite things, you can grab one word out a sentence
# and change it, array style almost
text['javascript'] = “JavaScript”
puts text
# also some cool stuff like the uppercase function
puts text.upcase
# also really cool:
50.times { puts text }
As you can see it’s not bad so far. The classes are pretty much the same idea. Simple, English like syntax and always a cool array of stuff to do
class SomeStuff
def moreStuff
coolVar = "this is a class"
puts coolVar.upcase
end
end
newClass = SomeStuff.new
newClass.moreStuff
# should output: THIS IS A CLASS
That’s all for now. The formatting I attempted to use in the code examples with most likely be taken out by WordPress’ WYSIWYG editor. I’d just like to take the time now and clear up that contrary to what some believe:
WYSIWYG = What you see Isn’t what you get
Leave a comment
Andy
March 19th, 2007 at 6:31 PM
I’ve been looking at Ruby for a while, it’s next on my “To Learn List” now that I have some tutorial DVDs.
Connor Wilson
March 19th, 2007 at 8:11 PM
I’m hesitant to even buy a book, but I would never go for a DVD (unless they were free of course :P).
A book you can at least sit down with and try to get it in your head.
Login »