Monday 23 February 2004 — This is close to 21 years old. Be careful.
Everyone’s linking to why’s (poignant) guide to ruby, and everyone seems to love it. Maybe I’m just an old fart, but it struck me as the work of a precocious and irritatingly cute tween-ager. I’d love to have more about Ruby and less about the author. Somebody get this guy an editor.
Comments
Ruby is very simple to learn. But there are some areas that are more complex underneath (closures) and quite complex (continuations).
When I need a technical book, I look for "Advanced" in the title. The elementary stuff is usually implicitly assumed, or can easily be looked up on the web. That is easier than skimming through pages of "hello world" programs.
I learned Ruby from The Pragmatic Programmer's Guide a couple of years ago, and I program in it almost exclusively now.
But I have to say that I'm absolutely in favor of someone, anyone paying serious attention to producing an easily available, free, introductory text for novice programmers. Hopefully the attention will generate some input from more seasoned authorities, and maybe we'll end up with a great source of both knowledge and wisdom for beginners.
I can't say it got me excited about the Ruby though. I don't know if it was just the examples, but I find Ruby to be almost as cryptic as Perl. For instance:
exit unless "restaurant".include? "aura"
The author talks about how the language makes good use of punctuation. It may make sense in Japanese, but in English, question marks go at the end of the sentence.
Python, on the other hand seems clearer:
if "aura" in "restaurant": sys.exit(-1)
His other example is even more confusing:
[toast, cheese, wine].each {|food| eat food}
What's going on here? Does the food eat itself? Again, Python is much more elegant (in my opinion, anyway)
for food in ['toast', 'cheese', 'wine']: eat(food)
I'll admit I'm a bit of a Python zealot and I should really learn about Ruby. But so far, Python is still king.
Nat
If you find his "humour" grating, best not to read it.
for food in ['toast', 'cheese', 'wine']: eat(food)
code is syntactically correct ruby as well. You just need an end after that line to specify that your for loop is done. (you could also do it with brackets or (blecch) a semicolon if you really wanted to keep it on one line)
richs@ess richs $ irb --noprompt
def eat(food)
p "Tasty, #{food}"
end
nil
for food in ['toast', 'cheese', 'wine']: eat(food)
end
"Tasty, toast"
"Tasty, cheese"
"Tasty, wine"
["toast", "cheese", "wine"]
Add a comment: