clorz
clorz

Reputation: 1133

Porting rails to java

I have a ruby on rails application and thinking about porting it to java. What are the things I should consider before that? How hard is that task in terms of changes required?

Any advice from the people who have walked this path is greatly appreciated.

Motivation: I have two web applications using same data. One is in java, another - rails. As a result, they both have databases and lots of stuff is sent back and forth and stored in copied tables. As an addition it is extremly slow. I can't move java to RoR, so thinking about what it'll take to move RoR to java (jvm that is).

Upvotes: 2

Views: 1382

Answers (5)

John Goodsen
John Goodsen

Reputation: 101

Check out playframework.org - it's a sweet web framework completely written in Java and the best Rails rip-off in Java I've seen to date. I ported a fairly simple app over to the Playframework in a few days. In some ways it's sweeter than Rails because of the way it uses Annotations to mix in code in a type safe manner. If you're a rails programmer with a Java background, you'll be productive almost instantly because the framework maps directly to the Rails world.

Upvotes: 0

vonconrad
vonconrad

Reputation: 25377

This may seem like an obvious solution, but have you tried running both applications with the same database? My company is currently migrating our software from PHP to Rails, and while we're re-coding components one-by-one, we let both applications use the same database. No need to send data back and forth, as long as you make sure the applications don't conflict.

Upvotes: 0

In general switching out a core component or framework means that you will essentially have to reimplement some or even lots of your application. Hence, you usually want a good reason to do so.

If I understand your question correctly you need to deploy on a platform without Ruby but with a JVM. In that case I would make it run with JRuby as the very first priority as this is with a very high probability the approach needing the least amount of work.

Upvotes: 2

Brian Agnew
Brian Agnew

Reputation: 272247

What's the motivation for porting this ?

If you need to integrate with Java libraries, there are numerous options available other than porting the whole app to Java.

If you need a direct port, then (as Chad has illustrated) JRuby may be the way to go.

If you want to do a complete rewrite, but keep the RoR paradigm, check out Grails, which is a JVM-based RoR equivalent using Groovy (a Java Virtual Machine-compatible language that allows you to bind in Java libraries)

Upvotes: 5

Chad Okere
Chad Okere

Reputation: 4578

If I were in your position, I would try running your Ruby code in JRuby which is an implementation of Ruby that runs on the JVM. It supports rails, which means you should be able to take your code and run it on the JVM.

Once that's done, you can start writing new features in java, and it should work with your old code transparently. You can also begin the task of rewriting some of your code in Java, without breaking comparability.

Upvotes: 11

Related Questions