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

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

···

On Tue, 28 Dec 2004 03:33:23 +0900, Leiradella, Andre V Matos Da Cunha <ANDRE.LEIRADELLA@bra.xerox.com> wrote:

Hi All,

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

--
Pretty women make us buy beer, ugly women make us drink beer

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" <ANDRE.LEIRADELLA@bra.xerox.com>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
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 (Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos), 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

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 :wink:

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

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/

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)

"Jeffrey Moss" <jeff@opendbms.com> 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

From: "Leiradella, Andre V Matos Da Cunha"

<ANDRE.LEIRADELLA@bra.xerox.com>

To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
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 (Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos), 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

···

----- Original Message -----
> interfaces?
>
> Best regards,
>
> Andre de Leiradella
>