Bare-bones Ruby

Discussion in 'Ruby' started by Leiradella, Andre V Matos Da Cunha, Dec 27, 2004.

  1. Hi All,

    This is my first submission to the ruby-talk list. I've been using Lua
    (http://www.lua.org) for some years now for some pet projects, which include
    FullMoon (http://www.geocities.com/andre_leiradella/#fullmoon), a plugin for
    the 3D modeler Moray that enables the authoring of other plugins in Lua.
    Plugins in FullMoon probably exist in higher number than those written in
    C/C++.

    I've been fighting with Lua to make it look like the object plugins are
    classes because Lua is not OO. Using a facility called metamethods, one can
    create an OO-like environment, but some things get just too confused to use
    like static class properties and calling inherited methods. I want OO
    because I want to enable plugin writers to extend other objects with ease
    and because I want to create a GUI for the plugins.

    I've been looking for a script language that could be used in Lua's place
    for FullMoon and I found Ruby. I downloaded it (3.4MB!) and I saw that it
    comes with a great set of modules. So my first questions to the list are:

    1) Is it possible to build Ruby without those modules? How?
    2) How do I embed Ruby in a host program?
    3) What are the functions that must be called to make Ruby load a program,
    to create an instance of a class defined in Ruby, to call methods with this
    instance etc.? Is this API documented somewhere?
    4) Does Ruby support multiple inheritance or something similar to Java's
    interfaces?

    Best regards,

    Andre de Leiradella
    Leiradella, Andre V Matos Da Cunha, Dec 27, 2004
    #1
    1. Advertising

  2. On Tue, 28 Dec 2004 03:33:23 +0900, Leiradella, Andre V Matos Da Cunha
    <> wrote:
    > Hi All,
    >
    > 4) Does Ruby support multiple inheritance or something similar to Java's
    > interfaces?
    >


    Ruby does not support multiple inheritance but provides a very neat
    way to reuse code: modules. Declaring a module and including it
    automatically makes all the methods available in your classes.

    Take a look at this:
    http://www.rubycentral.com/book/tut_modules.html

    Kind Regards,
    Ed
    --
    Pretty women make us buy beer, ugly women make us drink beer
    Edgardo Hames, Dec 27, 2004
    #2
    1. Advertising

  3. Leiradella, Andre V Matos Da Cunha

    Jeffrey Moss Guest

    There is an informative section on the Programming Ruby online book:

    http://www.rubycentral.com/book/ext_ruby.html

    Should be a good introduction to embedding the interpreter in your C
    program. It appears to do everything you're looking for.

    Not clear what you mean by "modules", most modules dont have to be built, so
    if you dont want them just delete the "lib" directory.

    -Jeff

    ----- Original Message -----
    From: "Leiradella, Andre V Matos Da Cunha" <>
    To: "ruby-talk ML" <>
    Sent: Monday, December 27, 2004 11:33 AM
    Subject: Bare-bones Ruby


    > Hi All,
    >
    > This is my first submission to the ruby-talk list. I've been using Lua
    > (http://www.lua.org) for some years now for some pet projects, which
    > include
    > FullMoon (http://www.geocities.com/andre_leiradella/#fullmoon), a plugin
    > for
    > the 3D modeler Moray that enables the authoring of other plugins in Lua.
    > Plugins in FullMoon probably exist in higher number than those written in
    > C/C++.
    >
    > I've been fighting with Lua to make it look like the object plugins are
    > classes because Lua is not OO. Using a facility called metamethods, one
    > can
    > create an OO-like environment, but some things get just too confused to
    > use
    > like static class properties and calling inherited methods. I want OO
    > because I want to enable plugin writers to extend other objects with ease
    > and because I want to create a GUI for the plugins.
    >
    > I've been looking for a script language that could be used in Lua's place
    > for FullMoon and I found Ruby. I downloaded it (3.4MB!) and I saw that it
    > comes with a great set of modules. So my first questions to the list are:
    >
    > 1) Is it possible to build Ruby without those modules? How?
    > 2) How do I embed Ruby in a host program?
    > 3) What are the functions that must be called to make Ruby load a program,
    > to create an instance of a class defined in Ruby, to call methods with
    > this
    > instance etc.? Is this API documented somewhere?
    > 4) Does Ruby support multiple inheritance or something similar to Java's
    > interfaces?
    >
    > Best regards,
    >
    > Andre de Leiradella
    >
    Jeffrey Moss, Dec 27, 2004
    #3
  4. Get yourself a copy of "Programming Ruby" (Pickaxe) by Dave Thomas and
    you find the answers for ALL your questions. And you will enjoy reading
    it too ;-)

    >
    > 1) Is it possible to build Ruby without those modules? How?


    After you build ruby you can use just a ruby executable without the
    standard library if you do not need the functionality it provides. As
    for built-in classes and modules, such as String, you will not be able
    to get without them as they are implemented internally in C and other
    parts of Ruby depend on them heavily.

    > 2) How do I embed Ruby in a host program?


    The book I mentioned has a very good chapter on embedding Ruby.

    > 3) What are the functions that must be called to make Ruby load a
    > program,
    > to create an instance of a class defined in Ruby, to call methods with
    > this
    > instance etc.? Is this API documented somewhere?


    I did not quite get the question, but if you mean the API between Ruby
    and extensions written in C, Pickaxe discusses it in great details too.

    > 4) Does Ruby support multiple inheritance or something similar to
    > Java's
    > interfaces?


    Ruby has mix-ins, implemented with modules. As for Java-like
    interfaces, you can easily do without them in Ruby, as Ruby uses so
    called duck-typing (see Pickaxe for details).

    >
    > Best regards,
    >
    > Andre de Leiradella
    >
    >


    Sincerely,
    Gennady Bystritsky
    Gennady Bystritsky, Dec 27, 2004
    #4
  5. Leiradella, Andre V Matos Da Cunha ha scritto:


    > I've been looking for a script language that could be used in Lua's place
    > for FullMoon and I found Ruby. I downloaded it (3.4MB!) and I saw that it
    > comes with a great set of modules. So my first questions to the list are:
    >
    > 1) Is it possible to build Ruby without those modules? How?


    most of the modules are pure ruby extensions or C extensions that can be
    loaded at runtime, not basicly needed. But ruby has more things builtin
    that Lua, I think (i.e. sockets are C extensions, SOAP is a ruby one,
    Array and Hash are builtins)

    > 2) How do I embed Ruby in a host program?


    There is the "programming ruby" documentation, but you may find usefule
    this pages:
    http://metaeditor.sourceforge.net/embed/
    http://www.rubygarden.org/ruby?EmbedRuby

    > 3) What are the functions that must be called to make Ruby load a program,
    > to create an instance of a class defined in Ruby, to call methods with this
    > instance etc.? Is this API documented somewhere?


    README.ext in the source distribution, I think.

    > 4) Does Ruby support multiple inheritance or something similar to Java's
    > interfaces?


    modules can be mixed in to fit for 99% of good uses of multiple
    inheritance, and callbacks like Module#included or Class#inherited can
    be used to simulate interfaces a-la java (if you look on the ruby
    application archive, raa.ruby-lang.org, you may find some pure ruby
    interface system implementations)
    gabriele renzi, Dec 27, 2004
    #5
  6. "Jeffrey Moss" <> schrieb im Newsbeitrag
    news:002301c4ec46$14eb0930$2c02a8c0@hans...
    > There is an informative section on the Programming Ruby online book:
    >
    > http://www.rubycentral.com/book/ext_ruby.html


    For easier reference and less scrolling: "Embedding a Ruby Interpreter" is
    located here:
    http://www.rubycentral.com/book/ext_ruby.html#S6

    Kind regards

    robert


    >
    > Should be a good introduction to embedding the interpreter in your C
    > program. It appears to do everything you're looking for.
    >
    > Not clear what you mean by "modules", most modules dont have to be

    built, so
    > if you dont want them just delete the "lib" directory.
    >
    > -Jeff
    >
    > ----- Original Message -----
    > From: "Leiradella, Andre V Matos Da Cunha"

    <>
    > To: "ruby-talk ML" <>
    > Sent: Monday, December 27, 2004 11:33 AM
    > Subject: Bare-bones Ruby
    >
    >
    > > Hi All,
    > >
    > > This is my first submission to the ruby-talk list. I've been using Lua
    > > (http://www.lua.org) for some years now for some pet projects, which
    > > include
    > > FullMoon (http://www.geocities.com/andre_leiradella/#fullmoon), a

    plugin
    > > for
    > > the 3D modeler Moray that enables the authoring of other plugins in

    Lua.
    > > Plugins in FullMoon probably exist in higher number than those written

    in
    > > C/C++.
    > >
    > > I've been fighting with Lua to make it look like the object plugins

    are
    > > classes because Lua is not OO. Using a facility called metamethods,

    one
    > > can
    > > create an OO-like environment, but some things get just too confused

    to
    > > use
    > > like static class properties and calling inherited methods. I want OO
    > > because I want to enable plugin writers to extend other objects with

    ease
    > > and because I want to create a GUI for the plugins.
    > >
    > > I've been looking for a script language that could be used in Lua's

    place
    > > for FullMoon and I found Ruby. I downloaded it (3.4MB!) and I saw that

    it
    > > comes with a great set of modules. So my first questions to the list

    are:
    > >
    > > 1) Is it possible to build Ruby without those modules? How?
    > > 2) How do I embed Ruby in a host program?
    > > 3) What are the functions that must be called to make Ruby load a

    program,
    > > to create an instance of a class defined in Ruby, to call methods with
    > > this
    > > instance etc.? Is this API documented somewhere?
    > > 4) Does Ruby support multiple inheritance or something similar to

    Java's
    > > interfaces?
    > >
    > > Best regards,
    > >
    > > Andre de Leiradella
    > >

    >
    >
    >
    Robert Klemme, Dec 28, 2004
    #6
    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. Leiradella, Andre V Matos Da Cunha

    RES: Bare-bones Ruby

    Leiradella, Andre V Matos Da Cunha, Dec 28, 2004, in forum: Ruby
    Replies:
    0
    Views:
    82
    Leiradella, Andre V Matos Da Cunha
    Dec 28, 2004
  2. Leiradella, Andre V Matos Da Cunha

    RES: Bare-bones Ruby

    Leiradella, Andre V Matos Da Cunha, Dec 28, 2004, in forum: Ruby
    Replies:
    0
    Views:
    109
    Leiradella, Andre V Matos Da Cunha
    Dec 28, 2004
  3. Leiradella, Andre V Matos Da Cunha

    RES: Bare-bones Ruby

    Leiradella, Andre V Matos Da Cunha, Dec 28, 2004, in forum: Ruby
    Replies:
    1
    Views:
    84
    rcoder
    Dec 28, 2004
  4. Leiradella, Andre V Matos Da Cunha

    RES: RES: Bare-bones Ruby

    Leiradella, Andre V Matos Da Cunha, Dec 29, 2004, in forum: Ruby
    Replies:
    1
    Views:
    300
    Stefan Schmiedl
    Dec 29, 2004
  5. Leiradella, Andre V Matos Da Cunha

    RES: RES: RES: Bare-bones Ruby

    Leiradella, Andre V Matos Da Cunha, Dec 29, 2004, in forum: Ruby
    Replies:
    0
    Views:
    134
    Leiradella, Andre V Matos Da Cunha
    Dec 29, 2004
Loading...

Share This Page