Irb and Ruby Separation

Discussion in 'Ruby' started by Nicholas Van Weerdenburg, Jan 14, 2005.

  1. I've been wondering about why are irb and ruby separate programs.

    Python combines the two concepts in its main executable, and I was
    wondering if there was a benefit to separating them.

    Thanks,
    Nick
    --
    Nicholas Van Weerdenburg
     
    Nicholas Van Weerdenburg, Jan 14, 2005
    #1
    1. Advertising

  2. Nicholas Van Weerdenburg wrote:
    > I've been wondering about why are irb and ruby separate programs.
    >
    > Python combines the two concepts in its main executable, and I was
    > wondering if there was a benefit to separating them.
    >
    > Thanks,
    > Nick


    They are not. irb is a ruby program. Here's the content of
    /usr/local/bin/irb:

    #!/usr/local/bin/ruby
    #
    # irb.rb - intaractive ruby
    # $Release Version: 0.7.3 $
    # $Revision: 1.2 $
    # $Date: 2002/11/19 02:00:18 $
    # by Keiju ISHITSUKA()
    #

    require "irb"

    if __FILE__ == $0
    IRB.start(__FILE__)
    else
    # check -e option
    if /^-e$/ =~ $0
    IRB.start(__FILE__)
    else
    IRB.setup(__FILE__)
    end
    end

    Gennady.
     
    Gennady Bystritksy, Jan 14, 2005
    #2
    1. Advertising

  3. Nicholas Van Weerdenburg wrote:

    > I've been wondering about why are irb and ruby separate programs.


    The benefit is that IRB is a Ruby program, making it easier to patch it
    or to do funky stuff. (Like I've done with the Breakpoint library.)

    I think it is a good thing to get above the C level whenever you can.
    There's a downside of course: IRB needs to re implement some of the
    functionality that Ruby already has. (It needed to implement it's own
    Lexer, for example, nowadays it could use Ripper instead, but it would
    still need to find out whether an expression is already finished or not.)
     
    Florian Gross, Jan 14, 2005
    #3
  4. Thanks.

    I guess my question might be better phrased "why doesn't running the
    ruby interpreter with no input not default to interactive mode (irb)
    such as with the python interpreter".

    I'm mostly curious for no practical reason. Just wondering if there is
    functionality or design benefits.

    On Sat, 15 Jan 2005 05:59:13 +0900, Gennady Bystritksy <> wrote:
    > Nicholas Van Weerdenburg wrote:
    > > I've been wondering about why are irb and ruby separate programs.
    > >
    > > Python combines the two concepts in its main executable, and I was
    > > wondering if there was a benefit to separating them.
    > >
    > > Thanks,
    > > Nick

    >
    > They are not. irb is a ruby program. Here's the content of
    > /usr/local/bin/irb:
    >
    > #!/usr/local/bin/ruby
    > #
    > # irb.rb - intaractive ruby
    > # $Release Version: 0.7.3 $
    > # $Revision: 1.2 $
    > # $Date: 2002/11/19 02:00:18 $
    > # by Keiju ISHITSUKA()
    > #
    >
    > require "irb"
    >
    > if __FILE__ == $0
    > IRB.start(__FILE__)
    > else
    > # check -e option
    > if /^-e$/ =~ $0
    > IRB.start(__FILE__)
    > else
    > IRB.setup(__FILE__)
    > end
    > end
    >
    > Gennady.
    >
    >


    --
    Nicholas Van Weerdenburg
     
    Nicholas Van Weerdenburg, Jan 14, 2005
    #4
  5. * Nicholas Van Weerdenburg (Jan 14, 2005 22:20):
    > I guess my question might be better phrased "why doesn't running the
    > ruby interpreter with no input not default to interactive mode (irb)
    > such as with the python interpreter".


    It interprets stdin instead. irb is a completely separate project from
    bin/ruby. It's much the same as the shell is separate from the kernel;
    an idea that seems to have been foregone by the Python developers.
    nikolai

    --
    ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
    ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
    ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Jan 14, 2005
    #5
  6. On Sat, 15 Jan 2005 06:36:06 +0900, Nikolai Weibull
    <> wrote:
    > * Nicholas Van Weerdenburg (Jan 14, 2005 22:20):
    > > I guess my question might be better phrased "why doesn't running the
    > > ruby interpreter with no input not default to interactive mode (irb)
    > > such as with the python interpreter".

    >
    > It interprets stdin instead. irb is a completely separate project from
    > bin/ruby. It's much the same as the shell is separate from the kernel;
    > an idea that seems to have been foregone by the Python developers.
    > nikolai
    >

    Cool:

    [shell prompt] ruby
    puts "Hello, world!"
    ^D
    Hello, world!
    [shell prompt]

    So, in effect it does essentially what's needed - just no shell-like
    interface, or any of the other benefits of irb.

    - Dimitri
     
    Dimitri Aivaliotis, Jan 14, 2005
    #6
  7. Nicholas Van Weerdenburg

    Guest

    Hi,

    At Sat, 15 Jan 2005 06:15:33 +0900,
    Nicholas Van Weerdenburg wrote in [ruby-talk:126498]:
    > I guess my question might be better phrased "why doesn't running the
    > ruby interpreter with no input not default to interactive mode (irb)
    > such as with the python interpreter".
    >
    > I'm mostly curious for no practical reason. Just wondering if there is
    > functionality or design benefits.


    It's in the ToDo list.

    * Built-in Interactive Ruby.


    Index: ruby.c
    ===================================================================
    RCS file: /cvs/ruby/src/ruby/ruby.c,v
    retrieving revision 1.94
    diff -U2 -p -r1.94 ruby.c
    --- ruby.c 24 Sep 2004 05:53:41 -0000 1.94
    +++ ruby.c 15 Jan 2005 05:34:34 -0000
    @@ -782,5 +782,15 @@ proc_options(argc, argv)
    }
    else if (strlen(script) == 1 && script[0] == '-') {
    - load_stdin();
    + if (!do_check && !do_loop && isatty(0) && isatty(1) && isatty(2) &&
    + !NIL_P(rb_rescue2(rb_require, (VALUE)"irb",
    + (VALUE (*)())0, (VALUE)0,
    + rb_eLoadError, (VALUE)0))) {
    + require_libraries();
    + ruby_eval_tree = NEW_CALL(NEW_LIT(rb_const_get(rb_cObject, rb_intern("IRB"))),
    + rb_intern("start"), 0);
    + }
    + else {
    + load_stdin();
    + }
    }
    else {


    --
    Nobu Nakada
     
    , Jan 15, 2005
    #7
  8. Nicholas Van Weerdenburg

    Csaba Henk Guest

    On 2005-01-15, <> wrote:
    > Hi,
    >
    > At Sat, 15 Jan 2005 06:15:33 +0900,
    > Nicholas Van Weerdenburg wrote in [ruby-talk:126498]:
    >> I guess my question might be better phrased "why doesn't running the
    >> ruby interpreter with no input not default to interactive mode (irb)
    >> such as with the python interpreter".
    >>
    >> I'm mostly curious for no practical reason. Just wondering if there is
    >> functionality or design benefits.

    >
    > It's in the ToDo list.
    >
    > * Built-in Interactive Ruby.


    I guess this transition mainly boils down to changing the parser/lexer
    used in irb (written in ruby) to the one used within ruby itself, doesn't
    it?

    Csab
     
    Csaba Henk, Jan 15, 2005
    #8
  9. * Csaba Henk (Jan 15, 2005 13:40):
    > > It's in the ToDo list.
    > >
    > > * Built-in Interactive Ruby.


    > I guess this transition mainly boils down to changing the parser/lexer
    > used in irb (written in ruby) to the one used within ruby itself,
    > doesn't it?


    Eh, the transition mainly boils down to the patch that was included,
    right?
    nikolai


    --
    ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
    ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
    ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Jan 15, 2005
    #9
  10. Nicholas Van Weerdenburg

    Csaba Henk Guest

    On 2005-01-15, Nikolai Weibull <> wrote:

    >> I guess this transition mainly boils down to changing the parser/lexer
    >> used in irb (written in ruby) to the one used within ruby itself,
    >> doesn't it?

    >
    > Eh, the transition mainly boils down to the patch that was included,
    > right?


    Uh, I tought that's just the top of the iceberg...

    Csab
     
    Csaba Henk, Jan 15, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne Liu

    Question on view and code separation

    Wayne Liu, Jul 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    344
    Wayne Liu
    Jul 25, 2003
  2. Helmut Jarausch

    BaseHTTPServer and priviledge separation?

    Helmut Jarausch, Jun 25, 2005, in forum: Python
    Replies:
    1
    Views:
    315
    Lee Harr
    Jun 25, 2005
  3. Sam Stephenson
    Replies:
    1
    Views:
    234
    Andrew Walrond
    Jun 18, 2005
  4. Replies:
    1
    Views:
    163
    Florian GroƟ
    Oct 26, 2005
  5. anne001
    Replies:
    1
    Views:
    279
    anne001
    Jun 27, 2006
Loading...

Share This Page