RE: mri development -> jruby prod, is this common?

I like how developing with mri is a bit faster, is it common for people
do
develop using mri, and then to deploy using jruby? (and maybe run tests
via jruby also to ensure things are working on the jvm side).

If so, are there any tips/tricks to do switching between different
runtimes
quicky?

I use rvm, but I can’t use a .rvmrc file then if I want to be able to
switch back and forth etc.

Hello. I don’t know how common it is to develop with MRI but use JRuby
in production, and it isn’t something I’ve done, but I immediately
thought of this talk when I saw your question. Xavier Shay: JRuby at Square on Vimeo
Xavier S. discusses doing exactly that while at Square. This is from
JRuby Conf 2012 I believe.
Cheers,
edub

Hi Ahmed, I’ve done this while testing gems as well as developing Rails
apps.

It’s not an issue - I’ve hit incompatibilities maybe twice - some gem
behaved differently on JRuby than on MRI - usually a monkey-patch
helped.
It requires a bit of discipline e.g. when you have different gems/code
to
do the same tasks in MRI and JRuby - it’s not common but we’ve used this
as
well e.g.
to zip files RubyZip had some issues for us (was 2 years back) thus
system
‘zip’ on MRI but Java’s API on JRuby since it performed better not
having
to shell out.

You hide such platform specific code behind an API used in the rest of
your
app while it sets up different “delegates” based on e.g.
defined?(JRUBY_VERSION)
Of couse rvm use jruby && rake test every once a while is a good idea

depends on how much experience you have with JRuby - it’s not that much
necessary unless you’re doing something concurrently e.g. with threads
or a
lot of unix-y process-ing.

On the topics of servers / JRuby for development - there are options and
you can even combine them.

I’ve seen the presentation from SQ if I recall correctly there’s a
strong
bias to “not use Tomcat” - I would say that’s a bit of an myth (esp.
irrelevant for running Rails on Java Servlets), but you do not need to
take
my word for it - companies such as SpringSource rely on TC.
What’s important is that JetPack last time I checked uses JRuby-Rack
thus
it’s portable - even if you use Java Servlet API extensions provided by
the
API as Warbler uses the very same and Trinidad (on top of TC) as well.
Thus
you’ll be mostly fine doing (JRuby specific) development on Trinidad and
deploying to JetPack or “plain” Jetty / Tomcat .

K.

Hi Ahmed,

It’s the we’ve been running for quite a few years now. MRI is much, much
faster for development, but jruby is great is a production environment,
not
only due to the simplicity of deployment (just a war file + sql/ddl) and
speed of the production runtime, but also because it allows us to send
compiled artefacts to our clients without having to divulge source code.

The only incompatibility we’ve found has been with nokogiri, which is
just
a wrapper around the native XML processors that are not quite
compatible.

We’ve developed wrapper scripts over time that let us run things under
jruby, just using the jruby-complete jar file. So we have jbundle and
jrake
that launch everything under jruby. Our wrappers also lock the version
of
jruby and the version of java, so different projects can have different
jruby and java versions (this is important if you use compiled
artefacts,
particularly compiled gems). We use rbenv just for MRI.

Regards,

Michael