Ruby & Perl

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call them
from Ruby would be awesome.

David

Here’s an example:

require ‘shell’
Shell.def_system_command(“txt2html”)
text_to_html = String.new
shell = Shell.new
shell.transact do
text_to_html = (shell.txt2html(“–infile”, ARGV[0],
“–endpreformat_trigger_lines”, “1”)).to_s
end
puts text_to_html

Save as ‘txt2html.rb’

Run ‘ruby txt2html.rb infile.txt’

Regards,

Mark

···

On Saturday, August 23, 2003, at 04:16 PM, David Corbin wrote:

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of
Perl
Modules is a long way from being matched in Ruby. Being able to call
them
from Ruby would be awesome.

David

In article 200308231616.18616.dcorbin@machturtle.com,

···

David Corbin dcorbin@machturtle.com wrote:

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call them
from Ruby would be awesome.

David

Until we have Ruby on Parrot (Cardinal) I don’t know that there will be
any satisfactory ways of acheiving what you’re trying to do.

What about using SOAP, XML-RPC or maybe even YAML as a liason between your
Ruby objects and your Perl objects?

Phil

I can bet I read a message long time ago about PerlInside in
ruby-talk.

I think that was the post, look at this thread or call the author
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/58626

···

il Sun, 24 Aug 2003 05:16:22 +0900, David Corbin dcorbin@machturtle.com ha scritto::

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call them
from Ruby would be awesome.

Hi David,

I have nothing to add to the technical discussion underway, but
thought it would be nice to know if there are any particular Perl
libraries you are after. It may spark someone’s creative juices. We
have a wiki page somewhere to track these.

Cheers,
Gavin

···

On Sunday, August 24, 2003, 6:16:22 AM, David wrote:

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call them
from Ruby would be awesome.

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of
Perl
Modules is a long way from being matched in Ruby. Being able to call
them
from Ruby would be awesome.

David

Here’s an example:

require ‘shell’
Shell.def_system_command(“txt2html”)
text_to_html = String.new
shell = Shell.new
shell.transact do
text_to_html = (shell.txt2html(“–infile”, ARGV[0],
“–endpreformat_trigger_lines”, “1”)).to_s
end
puts text_to_html

Save as ‘txt2html.rb’

Run ‘ruby txt2html.rb infile.txt’

I’m not talking about invoke system commands, I’m talking about having a
system for invoking perl librarys/methods/objects/methods, getting back
ruby-accessible objects.

···

On Saturday 23 August 2003 17:00, Mark Wilson wrote:

On Saturday, August 23, 2003, at 04:16 PM, David Corbin wrote:

Regards,

Mark

I’m sure that something like that is doable, but I was thinking that something
might be done by embedding the perl engine in ruby. Then, you’d have a
method for registering perl modules, that would return an ruby object with
wrapper methods for perl functions. I’m a little rusty on how Perl “objects”
are created, but I figure one can certainly do this: when I call wrapped Perl
method, the return object is analyzed - if it’s blessed, a new class is
created. Then, if its a hash or list, for every “nested object”, the same
logic is applied.

There very well could be fundamental flaws with this approach, but my instinct
says that we could open up a large class of functionality in this manner, and
make it’s use almost transparent to the end-user (i.e., it still looks like
the programmer is using Ruby objects).

David

···

On Sunday 24 August 2003 03:21, Phil Tomson wrote:

In article 200308231616.18616.dcorbin@machturtle.com,

David Corbin dcorbin@machturtle.com wrote:

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call them
from Ruby would be awesome.

David

Until we have Ruby on Parrot (Cardinal) I don’t know that there will be
any satisfactory ways of acheiving what you’re trying to do.

What about using SOAP, XML-RPC or maybe even YAML as a liason between your
Ruby objects and your Perl objects?

Phil

MIME::Tools (for constructing MIME messages), but I’m sure there will be
others :slight_smile:

···

On Sunday 24 August 2003 12:09, Gavin Sinclair wrote:

On Sunday, August 24, 2003, 6:16:22 AM, David wrote:

Has anyone considered some way to make Perl modules callable from Ruby?
Although I’m growing ot like Ruby quite a bit, the vast quantity of Perl
Modules is a long way from being matched in Ruby. Being able to call
them from Ruby would be awesome.

Hi David,

I have nothing to add to the technical discussion underway, but
thought it would be nice to know if there are any particular Perl
libraries you are after. It may spark someone’s creative juices. We
have a wiki page somewhere to track these.

Cheers,
Gavin

[snip]

I’m not talking about invoke system commands, I’m talking about having
a
system for invoking perl librarys/methods/objects/methods, getting back
ruby-accessible objects.
[snip]

I understand your point. However, if one wraps system command
invocations in Ruby classes and methods, what is the difference from an
interface perspective?

Regards,

Mark

···

On Saturday, August 23, 2003, at 06:26 PM, David Corbin wrote:

David Corbin dcorbin@machturtle.com writes:

I’m sure that something like that is doable, but I was thinking that
something might be done by embedding the perl engine in ruby.

Perl’s Inline::Ruby may help you if you’re happy to do things the
other way around.

···


print "Just another “,0 ? “Ruby” : “Perl”, " double agent\n”

I haven’t “claimed” it, but it’s somewhat on my to-do list after I do some
more work with PDF::Writer and get an initial release from that.

-austin

···

On Mon, 25 Aug 2003 09:37:13 +0900, David Corbin wrote:

On Sunday 24 August 2003 12:09, Gavin Sinclair wrote:

On Sunday, August 24, 2003, 6:16:22 AM, David wrote:

Has anyone considered some way to make Perl modules callable from
Ruby? Although I’m growing ot like Ruby quite a bit, the vast
quantity of Perl Modules is a long way from being matched in Ruby.
Being able to call them from Ruby would be awesome.
I have nothing to add to the technical discussion underway, but thought
it would be nice to know if there are any particular Perl libraries you
are after. It may spark someone’s creative juices. We have a wiki
page somewhere to track these.
MIME::Tools (for constructing MIME messages), but I’m sure there will be
others :slight_smile:


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.08.24
* 20.58.11

MIME::Tools (for constructing MIME messages),

I knew that before I openes this message…

but I’m sure there will be others :slight_smile:

…so I wouldn’t be so sure about this part :wink:

Seriously, I think MIME::Tools is indeed the module that is missed the
most by Perl-to-Ruby converts, and also one of the best MIME
implementations, too. I wonder is it possible to provide both Perl and
Ruby bindings from one codebase without doing a fork of it?

···

On Mon, Aug 25, 2003 at 09:37:13AM +0900, David Corbin wrote:


Dmitry Borodaenko

There’s little conceptual difference, but vast difference in implementation
complexity. I would expect the “magic tool” i’m looking at would examine the
perl objects and modules in question, and automagically expose the correct
interface object interface.

David

···

On Saturday 23 August 2003 18:37, Mark Wilson wrote:

On Saturday, August 23, 2003, at 06:26 PM, David Corbin wrote:
[snip]

I’m not talking about invoke system commands, I’m talking about having
a
system for invoking perl librarys/methods/objects/methods, getting back
ruby-accessible objects.
[snip]

I understand your point. However, if one wraps system command
invocations in Ruby classes and methods, what is the difference from an
interface perspective?

Regards,

Mark

Cool, but it seems to me the real payback would be the reverse.

···

On Sunday 24 August 2003 08:42, Simon Cozens wrote:

David Corbin dcorbin@machturtle.com writes:

I’m sure that something like that is doable, but I was thinking that
something might be done by embedding the perl engine in ruby.

Perl’s Inline::Ruby may help you if you’re happy to do things the
other way around.

Could you give a quick description of it, and explain what’s so good
about the Perl version?

Gavin

···

On Monday, August 25, 2003, 7:02:58 PM, Dmitry wrote:

Seriously, I think MIME::Tools is indeed the module that is missed the
most by Perl-to-Ruby converts, and also one of the best MIME
implementations, too. I wonder is it possible to provide both Perl and
Ruby bindings from one codebase without doing a fork of it?

You should forgive Mr. Cozens if he may view it differently.

http://simon-cozens.org/programmer/

He also has the ability to create hilarious jokes that turn into major
programming initiatives:

http://www.perl.com/pub/a/2001/04/01/parrot.htm

Regards,

Mark

···

On Sunday, August 24, 2003, at 08:52 AM, David Corbin wrote:

On Sunday 24 August 2003 08:42, Simon Cozens wrote:

David Corbin dcorbin@machturtle.com writes:

I’m sure that something like that is doable, but I was thinking that
something might be done by embedding the perl engine in ruby.

Perl’s Inline::Ruby may help you if you’re happy to do things the
other way around.

Cool, but it seems to me the real payback would be the reverse.

It seems that it may not be too difficult to make the reverse happen.
Inline::Ruby actually works both ways around, in that you can pass a
Perl subroutine reference to any Ruby method, and it will be
automagically turned into a Proc object which Ruby can then call.

Unlike most of the other Inline modules for Perl, Inline::Ruby can also
work standalone, and has an interface for rb_eval(), rb_call_function(),
rb_call_class_method(), rb_call_instance_method() etc…

I don’t know enough Ruby yet to know how this could be used, but it
seems that, as a worst case, someone could wrap this up to use the Shell
approach that Mark Wilson posted, and hide the nastiness from users.

Tony

···

On Sun, Aug 24, 2003 at 09:52:01PM +0900, David Corbin wrote:

Perl’s Inline::Ruby may help you if you’re happy to do things the
other way around.
Cool, but it seems to me the real payback would be the reverse.

Mark Wilson mwilson13@cox.net writes:

Cool, but it seems to me the real payback would be the reverse.

You should forgive Mr. Cozens if he may view it differently.

No, I think it’d be very cool to have Perl modules callable from Ruby;
I would very definitely use a lot more Ruby if I could. I was just
suggesting that Inline::Ruby shows it’s possible to exchange data between
the two languages, and may be a start at understanding how to implement
such a thing.

···


A Law of Computer Programming:
Make it possible for programmers to write in English
and you will find that programmers cannot write in English.

While that may be true, it isn’t the case here. While Simon’s done a
lot for Parrot, the joke provided the name and nothing else. The
project was well underway before the joke.

···

At 1:12 AM +0900 8/25/03, Mark Wilson wrote:

He also has the ability to create hilarious jokes that turn into
major programming initiatives:

http://www.perl.com/pub/a/2001/04/01/parrot.htm


Dan

--------------------------------------“it’s like this”-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

Simon Cozens wrote:

No, I think it’d be very cool to have Perl modules callable from Ruby;
I would very definitely use a lot more Ruby if I could. I was just
suggesting that Inline::Ruby shows it’s possible to exchange data
between
the two languages, and may be a start at understanding how to implement
such a thing.

Dan Sugalski wrote:

He also has the ability to create hilarious jokes that turn into major
programming initiatives:

http://www.perl.com/pub/a/2001/04/01/parrot.htm

While that may be true, it isn’t the case here. While Simon’s done a
lot for Parrot, the joke provided the name and nothing else. The
project was well underway before the joke.

And so I was wrong on both counts :slight_smile:

Regards,

Mark