Ruby to java or java to ruby converter

hi,

am a newbie to ruby and was wondering whether there is any ruby2java or
java2ruby converter? we are planning to compare both the languages based
on some benchmarks…so thought a converter would come in handy. any
suggestions?

thanx,
vinod

From: “Vinod Kone” [email protected]

am a newbie to ruby and was wondering whether there is any ruby2java or
java2ruby converter? we are planning to compare both the languages based
on some benchmarks…so thought a converter would come in handy. any
suggestions?

Benchmarks aside, you might take a look at JRuby:
http://jruby.codehaus.org/

It’s a port of Ruby running on the JVM. So you can mix Ruby and Java
code.

(One note about comparing languages based on benchmarks: Usually, all
that matters is whether the language is fast enough for the problem
you’re
trying to solve. If one language is “fast enough” and another language
is
“even more fast enough”, it doesn’t really matter… :slight_smile:

HTH,

Bill

Bill K. wrote:

From: “Vinod Kone” [email protected]

Benchmarks aside, you might take a look at JRuby:
http://jruby.codehaus.org/

It’s a port of Ruby running on the JVM. So you can mix Ruby and Java
code.

thanx Bill,

I looked at the jruby site b4 posting this…but couldnt understand
whether it solves my purpose? From the looks of it…it looks like ruby
running on top of JVM…isnt it? why would i want that…i mean all i
want was given a piece of code in java/ruby…i would want a piece of s/w
to convert it to ruby/java (approximately)

thx,
vinod

From: “Vinod Kone” [email protected]

I looked at the jruby site b4 posting this…but couldnt understand
whether it solves my purpose? From the looks of it…it looks like ruby
running on top of JVM…isnt it? why would i want that…i mean all i
want was given a piece of code in java/ruby…i would want a piece of s/w
to convert it to ruby/java (approximately)

Perhaps you could tell us more about what kind of benchmarks you
want to run in both languages. What sort of programming problems
do you want to solve with Java-or-Ruby? Web applications? Locally
installed applications with graphical user interfaces? Something else?

There are already websites out there with benchmarks comparing
given algorithms in many different programming languages. What do
you hope to learn by comparing a given piece of code in java/ruby?
Do you want to know which was easier to write? Do you want to
know which one ran faster?

Regards,

Bill

Perhaps you could tell us more about what kind of benchmarks you
want to run in both languages. What sort of programming problems
do you want to solve with Java-or-Ruby? Web applications? Locally
installed applications with graphical user interfaces? Something else?

There are already websites out there with benchmarks comparing
given algorithms in many different programming languages. What do
you hope to learn by comparing a given piece of code in java/ruby?
Do you want to know which was easier to write? Do you want to
know which one ran faster?

Regards,

Bill

i understand that comparing programming languages is a non-trivial issue
and it depends on the “type of tasks” that you want the program to do.
what we are trying to look into is how java and ruby fare w.r.t to
different “kind” of programs…for ex: memory intensive, io intensive,
regular expression matching etc. the benchmarks would be cpu time,
memory usage, length of code etc etc.

tx,
vinod

From: “Vinod Kone” [email protected]

i understand that comparing programming languages is a non-trivial issue
and it depends on the “type of tasks” that you want the program to do.
what we are trying to look into is how java and ruby fare w.r.t to
different “kind” of programs…for ex: memory intensive, io intensive,
regular expression matching etc. the benchmarks would be cpu time,
memory usage, length of code etc etc.

For length of code, Ruby seems to do very well: http://rubyurl.com/pvT

For CPU time, Ruby does poorly–and yet, here we all are, using Ruby to
code all manner of applications. Because Ruby is “fast enough” for most
things.

As matz, the designer of Ruby points out, computers are getting faster
and faster, so he may purposefully spend more CPU time if it saves
developer time:
http://www.rubyist.net/~matz/slides/ll2/mgp00020.html
http://www.rubyist.net/~matz/slides/ll2/mgp00006.html

Regards,

Bill

On Jan 21, 2007, at 10:41 pm, Vinod Kone wrote:

i understand that comparing programming languages is a non-trivial
issue
and it depends on the “type of tasks” that you want the program to do.
what we are trying to look into is how java and ruby fare w.r.t to
different “kind” of programs…for ex: memory intensive, io intensive,
regular expression matching etc. the benchmarks would be cpu time,
memory usage, length of code etc etc.

Personally, I think the best use of your time (and the most important
benchmark) would be estimating how much longer/shorter it would take
to develop in Java/Ruby. If the time to develop in Ruby is one week
less, and the cost to have a developer on a job is (say) £1000, all
you have to ask is will the Ruby version need more than £1000 of
hardware extra to run?

I will probably recommend soon that we upgrade our web servers to 4GB

  • RAM so we can start Mongrel clusters with impunity. We will easily
    save the cost of that in developer hours. Likewise with a
    particularly intensive data processing tool written in Ruby - it will
    cost far less to replace the CPU in our internal server than to
    rewrite the tool in another language.

Ashley

On Mon, Jan 22, 2007 at 05:16:51AM +0900, Vinod Kone wrote:

hi,

am a newbie to ruby and was wondering whether there is any ruby2java or
java2ruby converter? we are planning to compare both the languages based
on some benchmarks…so thought a converter would come in handy. any
suggestions?

I think if you want to do this the right way you shouldn’t use an
autoconvertor. Something written in one language may be written
differently in another language in a simpler, more efficient way than
perhaps an autoconvertor could detect.

e.g.: You might use a block in ruby to iterate over an array. The
ruby-to-java convertor would either have to know enough about the
running program to determine it was iteration, or it would have to
convert the block to an anonymous inner class, which is much more
heavyweigth than a ruby block, at least for iterating an array. That’s
ok because in Java you’d use a for loop anyway. Something you might do
with mixins in Ruby you might do with inheritance in Java, etc. Despite
the both of them being OO languages, the idioms used are different and
your convertor (unless you’ve got some AI hidden away) is not going to
be able to convert them properly.