

Ask HN: Recommendations for JRuby and MRI development - jfaucett

Hey HNers,<p>Im in the process of upgrading our rails application right now to rails4, and while Im working on all the gems, etc. I was hoping to be able go ahead and make it JRuby compatible - on the bet that it could be useful sometime down the road.<p>Well, I was hoping some of you Java&#x2F;Ruby&#x2F;JRuby expert hackers could give me some recommendations, links, really just any help would be really appreciated.<p>Heres some of the concrete problems Im having<p>1. How to deal with C-Ext Gems, If no alternative exists, this means I&#x27;ve gotta completely build a new one for JRuby, or is there a way to check RUBY_PLATFORM in the C-Ext Gem and require different files accordingly, whats the usual &quot;best practice&quot; here?<p>2. How to make Gems JRuby and MRI compatible. (should it be done in one Gem or should they be split into 2 gems?)<p>3. Best Practice for creating a JRuby &amp; MRI supported Gemfile in the Rails app.<p>4. Dealing with Background Jobs &#x2F; Concurrency. (big subject I know, but basically, are people using Resque with JRuby or just doing it with the threads provided by the JVM)<p>Also anything else you might have had problems with would interest me too.<p>Thanks in advance!
======
bobfirestone
I work on a jRuby/Rails project. The most difficult issue with going to jRuby
from MRI is c gems. For example if you are using the ruby racer to compile
assets you have to swap it out for the java based ruby rhino. If there isn't a
java version or equivalent then you are pretty much going to have to write it
yourself.

Writing standard ruby gems make sure you are thread safe and it will run in
both.

For background jobs look at sidekiq. It plays well with the jvm.

Unless you are in love with the JVM I would recommend taking a look at
rubinius. It is a ruby implementation written in ruby and C++. I hadn't looked
at it in a couple of years but the current version has gotten my attention.
Just tinkering locally the performance is excellent and no JVM related issues.

