4 ms·
Ask HN: Recommendations for JRuby and MRI development
Hey HNers,
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.
Well, I was hoping some of you Java/Ruby/JRuby expert hackers could give me some recommendations, links, really just any help would be really appreciated.
Heres some of the concrete problems Im having
1. How to deal with C-Ext Gems, If no alternative exists, this means I'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 "best practice" here?
2. How to make Gems JRuby and MRI compatible. (should it be done in one Gem or should they be split into 2 gems?)
3. Best Practice for creating a JRuby & MRI supported Gemfile in the Rails app.
4. Dealing with Background Jobs / Concurrency. (big subject I know, but basically, are people using Resque with JRuby or just doing it with the threads provided by the JVM)
Also anything else you might have had problems with would interest me too.
Thanks in advance!
- bobfirestone 13y agoI 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.