Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Invoking Ruby code from a low-level language?

Reply
Thread Tools

Invoking Ruby code from a low-level language?

 
 
Alex Fulton
Guest
Posts: n/a
 
      12-11-2008
Hi, my sincerest apologies if this question has already been answered
somewhere, but google didn't turn anything up...

I'm working on a small university research project which is trying to
create a network weathermap by creating a large distributed P2P network
of clients installed on ordinary users' home computers, and collecting
data by running traces etc between the different peers.

We want to use a high-level language and GUI library for the interface,
and FXRuby seems to be a good option for this, but, due to the sort of
computers this client is going to be deployed on (home users,
predominantly Windows, probably not tech-savvy and reluctant to make any
changes to their systems), most of them will probably not have a Ruby
interpreter installed. Rather than forcing people to download Ruby and
Fox and install them themselves, in addition to installing our client,
we would prefer to be able to bundle the Ruby interpreter and GUI
libraries into our application (as dynamic libraries or something) and
then write most of the program in C (the startup code, the
communications layer, etc), and only have the user-interaction stuff
written in Ruby.

So, is it possible to have a C program that invokes Ruby code via an
interpreter library? I'm sure I've seen some apps do this with Python,
but I'm not sure if it's possible with Ruby or not...

Thanks,
Alex Fulton
(Computer Science department, University of Auckland, New Zealand)
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Marc Heiler
Guest
Posts: n/a
 
      12-11-2008
> Rather than forcing people to download Ruby and
> Fox and install them themselves, in addition to installing our client,
> we would prefer to be able to bundle the Ruby interpreter and GUI
> libraries into our application (as dynamic libraries or something) and
> then write most of the program in C (the startup code, the
> communications layer, etc), and only have the user-interaction stuff
> written in Ruby.


Have a look at http://www.erikveen.dds.nl/rubyscript2exe/

Also you may want to look at Ruby-C
http://www.rubyinside.com/how-to-cre...nutes-100.html
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Alex Fulton
Guest
Posts: n/a
 
      12-11-2008
> Have a look at http://www.erikveen.dds.nl/rubyscript2exe/

That looks perfect. Not exactly what I had in mind, but it should serve
our purposes admirably.

Thanks very much!

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      12-12-2008
Alex Fulton wrote:
>> Have a look at http://www.erikveen.dds.nl/rubyscript2exe/

>
> That looks perfect. Not exactly what I had in mind, but it should serve
> our purposes admirably.


Have a look at Shoes. It's a complete platform built around Ruby, with both
installers and a package system - Shy. I would compare it favorably to the old
Amulet GUI for situations like weather maps.
 
Reply With Quote
 
Reid Thompson
Guest
Posts: n/a
 
      12-12-2008
Alex Fulton wrote:
> Hi, my sincerest apologies if this question has already been answered
> somewhere, but google didn't turn anything up...
>
> I'm working on a small university research project which is trying to
> create a network weathermap by creating a large distributed P2P network
> of clients installed on ordinary users' home computers, and collecting
> data by running traces etc between the different peers.
>
> We want to use a high-level language and GUI library for the interface,
> and FXRuby seems to be a good option for this, but, due to the sort of
> computers this client is going to be deployed on (home users,
> predominantly Windows, probably not tech-savvy and reluctant to make any
> changes to their systems), most of them will probably not have a Ruby
> interpreter installed. Rather than forcing people to download Ruby and
> Fox and install them themselves, in addition to installing our client,
> we would prefer to be able to bundle the Ruby interpreter and GUI
> libraries into our application (as dynamic libraries or something) and
> then write most of the program in C (the startup code, the
> communications layer, etc), and only have the user-interaction stuff
> written in Ruby.
>
> So, is it possible to have a C program that invokes Ruby code via an
> interpreter library? I'm sure I've seen some apps do this with Python,
> but I'm not sure if it's possible with Ruby or not...
>
> Thanks,
> Alex Fulton
> (Computer Science department, University of Auckland, New Zealand)


see the section "Embedding a Ruby Interpreter" in the pickaxe book and google
for the same for examples...

 
Reply With Quote
 
Jeremy Hinegardner
Guest
Posts: n/a
 
      12-16-2008
On Fri, Dec 12, 2008 at 07:59:39AM +0900, Alex Fulton wrote:
> Hi, my sincerest apologies if this question has already been answered
> somewhere, but google didn't turn anything up...
>
> I'm working on a small university research project which is trying to
> create a network weathermap by creating a large distributed P2P network
> of clients installed on ordinary users' home computers, and collecting
> data by running traces etc between the different peers.
>
> We want to use a high-level language and GUI library for the interface,
> and FXRuby seems to be a good option for this, but, due to the sort of
> computers this client is going to be deployed on (home users,
> predominantly Windows, probably not tech-savvy and reluctant to make any
> changes to their systems), most of them will probably not have a Ruby
> interpreter installed. Rather than forcing people to download Ruby and
> Fox and install them themselves, in addition to installing our client,
> we would prefer to be able to bundle the Ruby interpreter and GUI
> libraries into our application (as dynamic libraries or something) and
> then write most of the program in C (the startup code, the
> communications layer, etc), and only have the user-interaction stuff
> written in Ruby.
>
> So, is it possible to have a C program that invokes Ruby code via an
> interpreter library? I'm sure I've seen some apps do this with Python,
> but I'm not sure if it's possible with Ruby or not...


The 3 different ways to do this that I know of are:

- Shoes : http://shoooes.net/
- rubyscript2exe : http://www.erikveen.dds.nl/rubyscript2exe/
- Crate : http://copiousfreetime.rubyforge.org/crate/

Of the 3, Shoes has the gui support, and is probably the easiest to get going
with. Crate may work the best if you have other libraries to compile against
for your application to work.

Disclaimer: I'm the author of crate.

enjoy,

-jeremy

--
================================================== ======================
Jeremy Hinegardner http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
Alex Fulton
Guest
Posts: n/a
 
      12-16-2008
Wow, thanks for the replies everyone. This has given me a lot of
material to get going on (and my boss is now getting irate because I'm
spending too much time researching options and not enough time actually
coding ).

But I've done some research on embedding ruby interpreters (via ruby.h),
and while it seems like this task should be almost trivially easy, I
can't seem to find a copy of the actual embedded interpreter library and
headers. I did a search on my computer (a Mac) for ruby.h, and it turned
up some platform-specific ruby embedding stuff for making OSX apps, but
I'm interested in a more generic solution.

Any thoughts?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jeremy Hinegardner
Guest
Posts: n/a
 
      12-16-2008
On Wed, Dec 17, 2008 at 05:22:10AM +0900, Alex Fulton wrote:
> Wow, thanks for the replies everyone. This has given me a lot of
> material to get going on (and my boss is now getting irate because I'm
> spending too much time researching options and not enough time actually
> coding ).
>
> But I've done some research on embedding ruby interpreters (via ruby.h),
> and while it seems like this task should be almost trivially easy, I
> can't seem to find a copy of the actual embedded interpreter library and
> headers. I did a search on my computer (a Mac) for ruby.h, and it turned
> up some platform-specific ruby embedding stuff for making OSX apps, but
> I'm interested in a more generic solution.
>
> Any thoughts?


There isn't anything different to link against for the embedded ruby interpreter
vs the noral interpreter. Its the same library libruby or libruby-static
depending on your compilation shared/static needs. The ruby.h that you found is
probably the ruby.h that you need to look at. On my Mac, the ruby.h is:

mac shipped ruby : /usr/lib/ruby/1.8/universal-darwin9.0/ruby.h
ports ruby : /opt/local/lib/ruby/1.8/i686-darwin9.5.0/ruby.h

One thing you could do to see how to build an application that uses embedded
ruby is to look at crate. It is has a very thin wrapper around embedded
ruby.

http://github.com/copiousfreetime/cr...a/crate_boot.c

Pretty much everything I used to figure out embedded ruby was
http://metaeditor.sourceforge.net/embed/ and the 'Embedding a Ruby Interpreter'
section in the Programming Ruby 2nd ed.

hopefully that will help some.

enjoy,

-jeremy
--
================================================== ======================
Jeremy Hinegardner (E-Mail Removed)


 
Reply With Quote
 
Alex Fulton
Guest
Posts: n/a
 
      12-16-2008
Great, thanks very much! It's good to hear from another Mac user, as
different platforms seem to have vastly different ways of dealing with
this.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jeremy Hinegardner
Guest
Posts: n/a
 
      12-16-2008
On Wed, Dec 17, 2008 at 06:23:58AM +0900, Alex Fulton wrote:
> Great, thanks very much! It's good to hear from another Mac user, as
> different platforms seem to have vastly different ways of dealing with
> this.


Easiest/Best way is to just download the ruby tarball and look at the ruby.h
that ships. That works on every platform .

enjoy,

-jeremy

--
================================================== ======================
Jeremy Hinegardner (E-Mail Removed)


 
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
SoapException when invoking a .NET webservice from java code. anil ASP .Net Web Services 0 06-02-2008 01:14 PM
Invoking Page_Unload from a C# code behind module =?Utf-8?B?QW5kcmV3IFZpY2tlcnM=?= ASP .Net 4 12-03-2007 06:59 PM
Invoking serverside code from a webpage Thomas Korsgaard Java 2 06-06-2007 10:58 AM
Invoking a batch file with Ruby on Windows brian.kejser@protexis.com Ruby 1 08-21-2006 12:04 AM
org.eclipse.ant.core.AntSecurityException Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". jygoo Java 1 03-22-2006 06:04 PM



Advertisments