Bare-bones Ruby

  • Thread starter Leiradella, Andre V Matos Da Cunha
  • Start date
L

Leiradella, Andre V Matos Da Cunha

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
 
J

Jeffrey Moss

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" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Monday, December 27, 2004 11:33 AM
Subject: Bare-bones Ruby
 
G

Gennady Bystritsky

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
 
G

gabriele renzi

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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top