Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Bare-bones Ruby

Reply
Thread Tools

Bare-bones Ruby

 
 
Leiradella, Andre V Matos Da Cunha
Guest
Posts: n/a
 
      12-27-2004
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


 
Reply With Quote
 
 
 
 
Edgardo Hames
Guest
Posts: n/a
 
      12-27-2004
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


 
Reply With Quote
 
 
 
 
Jeffrey Moss
Guest
Posts: n/a
 
      12-27-2004
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" <ruby->
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
>




 
Reply With Quote
 
Gennady Bystritsky
Guest
Posts: n/a
 
      12-27-2004
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



 
Reply With Quote
 
gabriele renzi
Guest
Posts: n/a
 
      12-27-2004
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)
 
Reply With Quote
 
Robert Klemme
Guest
Posts: n/a
 
      12-28-2004

"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" <ruby->
> 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
> >

>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby extension (C++) on OS X [ruby 1.8.2] and Google-Sketchup [ruby 1.8.5] Nicholas Ruby 3 01-28-2007 01:48 AM
The Ruby Edge - Digg for Ruby and Ruby On Rails roschler Ruby 0 10-15-2006 11:35 PM
ruby-talk, comp.lang.ruby, ruby-talk-google Phrogz Ruby 4 09-05-2006 08:19 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge guillaume.pierronnet@ratp.fr Ruby 0 08-31-2003 11:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57