From: Vladimir Sizikov Date: 2008-07-28T05:30:05+09:00 Subject: [ruby-core:18002] Re: RUBY_ENGINE? Hi, On Sat, Jul 26, 2008 at 5:09 AM, Tanaka Akira wrote: > I think > > begin > require "zlib" > rescue LoadError > raise "no zlib" > end > > or > > require "zlib" > > is much better becuase it works well with other engines if > it provide zlib. I agree, that in this case there is need for RUBY_ENGINE, but there are other use cases when RUBY_ENGINE is much more preferable way. We get constant flow of questions from users on how to detect the current implementation. One of the typical cases is Rails database config. JRuby uses different drivers and slightly different configuration options, so having a standard way to detect JRuby would be great. The same most probably will be true for IronRuby, etc. And sometimes users need to use different gems for different implementations for various reasons. Begin-rescue is not the best/performant way to do that. Here's the example of rails database configuration: if defined? JRUBY_VERSION gem 'activerecord-jdbc-adapter' require 'jdbc_adapter' adapter = 'jdbcmysql' else adapter = 'mysql' end Add a couple more implementations with custom ways to detect them and you have a mess. Thanks, --Vladimir