JRuby

Hi,

I am learning to use JRuby. Currently just started reading the documents.
From a glimpse, I got an impression that JRuby enables you to use java
classes in your ruby program. However, I am more interested in how to use
ruby script in java applications, because it is easier to adopt ruby in Java
environment (for commercial purpose) rather than vice versa.

Although the document mentioned that JRuby enables you to embed a ruby
interpreter into your java application, I have not seen any document or
samples on this. Could any one give me a hint? Preferrably several line of
code to get a look and fee.

Thanks a lot!

Shannon

···

STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

Shannon Fang wrote:

Although the document mentioned that JRuby enables you to embed a ruby
interpreter into your java application, I have not seen any document or
samples on this. Could any one give me a hint? Preferrably several line of
code to get a look and fee.

Hi Shannon,

We’re a little short on documentation in some areas on JRuby. But it’s
pretty easy to embed the JRuby interpreter. Something like this (beware,
untested):

Ruby runtime = org.jruby.Ruby.getDefaultInstance();
runtime.evalScript(“puts 1 + 2”);

That’s about it. You can also pass in a stream of Ruby source instead,
to evaluate bigger scripts. The docs on JRuby’s Java support should be
able to help you with the rest.

You may be able to find someone with some more interesting sample code
on the jruby-user mailing list.
By the way, we would be grateful if someone gave us a good sample
application that embeds JRuby to distribute with our sample code.

/Anders - your friendly neighborhood JRuby developer

···

A n d e r s B e n g t s s o n | ndrsbngtssn@yahoo.se
Stockholm, Sweden |


Gratis e-mail resten av livet på www.yahoo.se/mail
Busenkelt!

Hi Anders,

Thanks. I will let you know my test result on JRuby. BTW, I’m also very
interested in your effort of trying to compile ruby into Java Byte Code.
Is it under development now? And how about compile Ruby into Java SOURCE
code?

I look forward to see greate success of JRuby, and Ruby itself. I do
hope that Ruby is widely accepted in commercial environment. It can
drastically improve efficiency and produce bug-less and easy
maintainable code…

Shannon

···

On Fri, 13 Dec 2002 05:11:02 +0900 Anders Bengtsson ndrsbngtssn@yahoo.se wrote:

Shannon Fang wrote:

Although the document mentioned that JRuby enables you to embed a ruby
interpreter into your java application, I have not seen any document or
samples on this. Could any one give me a hint? Preferrably several line of
code to get a look and fee.

Hi Shannon,

We’re a little short on documentation in some areas on JRuby. But it’s
pretty easy to embed the JRuby interpreter. Something like this (beware,
untested):

Ruby runtime = org.jruby.Ruby.getDefaultInstance();
runtime.evalScript(“puts 1 + 2”);

That’s about it. You can also pass in a stream of Ruby source instead,
to evaluate bigger scripts. The docs on JRuby’s Java support should be
able to help you with the rest.

You may be able to find someone with some more interesting sample code
on the jruby-user mailing list.
By the way, we would be grateful if someone gave us a good sample
application that embeds JRuby to distribute with our sample code.

/Anders - your friendly neighborhood JRuby developer

A n d e r s B e n g t s s o n | ndrsbngtssn@yahoo.se
Stockholm, Sweden |


Gratis e-mail resten av livet p~{e ~}www.yahoo.se/mail
Busenkelt!

Shannon Fang wrote:

Thanks. I will let you know my test result on JRuby. BTW, I’m also very
interested in your effort of trying to compile ruby into Java Byte Code.
Is it under development now? And how about compile Ruby into Java SOURCE
code?

I’ve started on the compiler, but so far it can only compile a few
statements. There are other areas in JRuby that needs more attention, so
more work on the compiler may have to wait.
Compiling into Java source code is a little easier than generating
bytecode, but also a little less practical. It could probably be done
using much of the same code as the bytecode compiler.

/Anders

···

A n d e r s B e n g t s s o n | ndrsbngtssn@yahoo.se
Stockholm, Sweden |


Följ VM på nära håll på Yahoo!s officielle VM-sajt www.yahoo.se/vm2002
Håll dig ajour med nyheter och resultat, med vinnare och förlorare…

Hi,

Compiling into Java source code is a little easier than generating
bytecode, but also a little less practical. It could probably be done
using much of the same code as the bytecode compiler.

I think compiling into java source code is very useful, simply for
political reason. If I can convert Ruby code into Java source, I can
easily impress my boss about the speed that I can program in Java. It is
so significant that I think it will make Ruby easily acceptable for
business usage. While Ruby is more mature (for example, Rite?) no body
need to convert Ruby into Java again.

What do you think?

Shannon

···

On Sat, 14 Dec 2002 10:46:50 +0900 Anders Bengtsson ndrsbngtssn@yahoo.se wrote:

I think compiling into java source code is very useful, simply for
political reason. If I can convert Ruby code into Java source, I can
easily impress my boss about the speed that I can program in Java. It is
so significant that I think it will make Ruby easily acceptable for
business usage. While Ruby is more mature (for example, Rite?) no body
need to convert Ruby into Java again.

What do you think?

I think if your boss saw the java code that ANY ‘cross language’ converter
spit out, he’d forbid you from ever using it.

It’s one thing to be able to turn ruby into java, it’s another thing entirely
from being able to maintain that java code later. And if you can’t ever
maintain it, you have to go to the source, which is ruby. From his point of
view, that’s no different than not having this java intermediary to begin with.

Hello Shannon,

Saturday, December 14, 2002, 5:21:23 AM, you wrote:

I think compiling into java source code is very useful, simply for
political reason. If I can convert Ruby code into Java source, I can
easily impress my boss about the speed that I can program in Java. It is

this code will be completely unreadable and unmodifiable. ruby is
dynamic language and translating it to java will be not better than
sending to boss C sources of ruby implementation with “now i write
programs in C” statement :slight_smile:

···


Best regards,
Bulat mailto:bulatz@integ.ru