On Mar 12, 2007, at 1:34 AM, 7stud 7stud wrote:

> Marc Heiler wrote:
>> on IRC it happens too often
>> that people on rails dont know irb, and it can
>> be frustrating to tutor people that are only, mostly interested
>> in rails)
>>
>
> I don't understand the distinction between "learning irb" and  
> "learning
> Ruby".   For instance, if I am going to write a hello world program, I
> open up a text editor, type in the code, save it, and then run it by
> typing:
>
> ruby myProgram.rb
>
> I realize that you could do the same thing in irb, but editing is  
> easier
> in a text file.  So, as far as I can tell, you don't ever have to use
> irb to learn Ruby.  Is there something important about irb that I am
> missing?

I don't think you're missing anything. If you use a text editor with  
first-class support for Ruby (e.g., TextMate on OS X), your need for  
irb rapidly approaches zero.

Irb is often cited as a great way to do exploratory coding such as  
checking on what methods are available to an object. I can do  
exploratory coding without firing up irb because I can evaluate code  
snippets from within a TextMate edit buffer. Here is an example, cut  
from TextMate and pasted here:

<code>
(Array.new.methods - Object.new.methods).sort # => ["&", "*", "+",  
"-", "<<", "<=>", "[]", "[]=", "all?", "any?", "assoc", "at",  
"clear", "collect", "collect!", "compact", "compact!", "concat",  
"delete", "delete_at", "delete_if", "detect", "each", "each_index",  
"each_with_index", "empty?", "entries", "fetch", "fill", "find",  
"find_all", "first", "flatten", "flatten!", "grep", "include?",  
"index", "indexes", "indices", "inject", "insert", "join", "last",  
"length", "map", "map!", "max", "member?", "min", "nitems", "pack",  
"partition", "pop", "push", "rassoc", "reject", "reject!", "replace",  
"reverse", "reverse!", "reverse_each", "rindex", "select", "shift",  
"size", "slice", "slice!", "sort", "sort!", "sort_by", "to_ary",  
"transpose", "uniq", "uniq!", "unshift", "values_at", "zip", "|"]
</code>

Further, in a TextMate edit buffer, I can highlight any method name  
and get the ri documentation on the method just by hitting ctrl-H. I  
also find it easy to run unit tests and benchmarks from within  
TextMate -- two things I find awkward to do from irb.

But my point is not to sing the praises of TextMate. I like a lot,  
but there are other editors that can perform the same or similar  
feats. My main point is a really good code editor trumps irb.

Regards, Morton