Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
Hi,
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
I’m a huge fan of irb. I primarily seem to do 2. but perhaps
more than occasionally. I tend to keep an irb window open at
all times and frequently try out ideas while writing ruby code
in a file. I’ll do 1. occasionally; I think it’s been quick hacks
like some one-off processing of a file that I could just do from
irb and not bother typing into a source file (but more complex
than I wanted to do with -e).
I also on occasion have done a variation of 2. which is to start
IRB at the bottom of my main source file ala:
require ‘IRB’
IRB.start
so I can interactively try out objects defined in my main
program… (I think I’ve tended to use this variation only
when I haven’t had automated unit tests.)
Regards,
Bill
From: “Jason Watkins” jason_watkins@pobox.com
I do both, though I use 1. mostly for small programs (no new classes).
I would really like to see Ruby have something like Dr. Scheme – an
upper window that saves to a file in which one could write classes and
methods (the model) and a lower window that is interactive (the
controller), with the ability to run the code in the upper window in
order to set the environment for the interactive window.
It’s possible that FreeRIDE has or will have this, but I haven’t yet
set it up because I use a Mac and have not been able to get Fox and
FXRuby working with my preferred Ruby (1.8p2).
Regards,
Mark
On Sunday, June 1, 2003, at 10:02 PM, Jason Watkins wrote:
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a
shell
to test your code
Jason Watkins wrote:
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
You forgot one:
3.) Pure Test Driven Development, from RubyUnit.
Important:
If you never run Ruby under Windows, skip this post!
DOS shell is rubbish, I use it as a last resort and fear the
sight of a DOS box when it flashes up because it’s going
to close before I get to reading what was in it.
I use Ruby Development Environment
http://raa.ruby-lang.org/list.rhtml?name=rde
It’s easy to run irb from within it …
… but it’s hardly necessary because I keep a tabbed page open
(usually called Blank{n} - no need to think of a name or where
to save it), type (e.g.)
p 6 + 4
hit F5, and the result is displayed in the output window.
If I’m running a script that produces an output file, that file
can be open in another page and if it has changed since the last
time, RDE asks if I want to reload it. Click YES and there’s the
updated output from the script I just ran.
I can have several scripts “in progress”, cut and paste chunks
from one to another etc. and test bits before “committing”.
If someone posts an irb script, I can copy it into an edit page
and use the RDE RunBy facility to convert it with this Ruby snippet:
ARGF.each{|lin|
if lin =~ /\s*irb(\w+):\d{3}:\S+\s/
print $’
else
print ‘#.->’, lin
end
}
I don’t really need it to be any easier than that.
No doubt there are some slick Vi(m) / Emacs setups out there
and I like the FreeRIDE project’s aims and values:
Irb is brilliant, and I don’t think I would have
stayed with Ruby had it not been available at the start
but IMHO, it’s not for coding with.
daz
“Jason Watkins” jason_watkins@pobox.com wrote:
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
Just out of curiousity, how often do you find yourself:
1.) Write ruby in the interactive interpreter
2.) Write ruby in files, occasionally calling the interpreter from a shell
to test your code
i always have an irb window open, but code in files (sometimes i even have
tests! )
mostly i do stuff like this in the irb window:
require ‘postgres’
PGConn.new # oops error
PGconn.new # ah yes - that’s how it’s spelled
also i often do this
require ‘rbtree’
(RBTree.new.methods - Object.new.methods).sort
or
object.methods
object.constants
or
class Foo; FOO = 42; end
class Bar < Foo; end
Bar::FOO # does this work?
or sometimes
require ‘class_in_progress’
ClassInProgress.method args # repeat these two many times…
instead of using the ‘if $0 == FILE’ bit…
you get the idea. i also do a lot of database manipulate in irb instead of
the native rdbms shell…
in summary - i love irb.
-a
====================================
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p % ^) .intern’
====================================