Ruby vs. JRuby - alternatives or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
as I'm working on packaging new JRuby for F19, I've started thinking about approach to coexistence of JRuby and cRuby - and I'd like to hear some opinions on that.
On the first look, cRuby and JRuby seem to be an appropriate candidates for using alternatives (which solves the problem of automatically generated dependencies from shebangs and switching interpreters by root). But - thinking of it further, I'm not sure whether cRuby and JRuby are alternatives. Reasons:

1. extension gems - there are gems with extensions
a) only for cRuby
b) only for JRuby
c) for both implementations.
Obviously, most of the cRuby-only extension gems are only usable with cRuby and vice versa for JRuby (exceptions are gems that contain pure Ruby fallback when extension cannot be loaded). For these extension gems, cRuby and JRuby are not alternatives, AFAICS.
2. pure Ruby gems using cRuby specific functions - some Ruby functions, for example fork(), cannot be used on JRuby, because JRuby doesn't support fork() - so if a gem uses fork, it only works on cRuby.

So cRuby and JRuby are mostly alternatives, but not completely. Therefore we (ruby-sig folks) came up with an idea that we call multiruby [1], which allows user (a user who knows what he's doing - for RPM packaged applications, packager will choose how to run them, possibly modifying shebangs) to choose the interpreter on invocation. The intepreter defaults to cRuby (also, compared to alternatives, this approach brings the benefit on non-root user being able to choose/switch the interpreter). In this scheme, /usr/bin/ruby would be a shell script that would route the commands either to /usr/bin/ruby-mri or /usr/bin/jruby. I know that this is no standard mechanism, but it doesn't break any expectations and brings some interesting functionality.

For example
ruby foo.rb # behaves as it now does
gem install foo # behaves as it now does
ruby _jruby_ foo.rb # invokes foo.rb with jruby
gem _jruby_ install foo # runs "gem install" with jruby

The inspiration for this approach is actually taken from RubyGems binary wrappers (as documented in [2]). The wrappers let you choose gem version on the wrapper execution, e.g. "rake _0.7.3_" will run rake 0.7.3, so the multiruby concept would not be anything strange to Ruby folks.
Thoughts? Would this be an acceptable approach?
Thanks.

[1] https://github.com/bkabrda/multiruby
[2] http://guides.rubygems.org/command-reference/#gem_install, section about wrappers

-- 
Regards,
Bohuslav "Slavek" Kabrda.
--
packaging mailing list
packaging@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/packaging



[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux