JRuby - The enterprise view

JRuby - The enterprise view

JRuby is often portrayed as the Ruby with brilliant Garbage Collection and native threads but poor startup time and large memory overhead. But how can JRuby really help you in a project, especially when you deal with large corporations that live in the Java world.

84cd9fd20832381fc78084aac4cb4b6c?s=128

Leif Gensert

November 13, 2013
Tweet

Transcript

  1. The enterprise view

  2. One of the best GCs in the world Native Threading

    Profiled Optimizations Native JIT True Parallelism (slow startup time)
  3. None
  4. Recap “The Java World”

  5. Let me tell you a story

  6. The Migration

  7. Java Database Connectivity (JDBC)

  8. require 'java' ! java_import 'oracle.jdbc.OracleDriver' java_import 'java.sql.DriverManager' ! class OracleConnection

    ! def initialize (user, passwd, url) oradriver = OracleDriver.new ! DriverManager.registerDriver oradriver @conn = DriverManager.get_connection url, user, passwd end ! def create_statement() @conn.create_statement end ! def prepare_statement(sql) @conn.prepare_statement sql end ! def commit() @conn.commit end ! end The Oracle Way stmnt = conn.create_statement result_set = stmnt.execute_query 'select * from users' ! while result_set.next result_set.get_object('ID') end
  9. require 'java' ! java_import 'oracle.jdbc.OracleDriver' java_import 'java.sql.DriverManager' require 'sequel' !

    class OracleConnection def initialize (user, passwd, host, port, sid) url = "jdbc:oracle:thin:#{user}/#{passwd}@#{host}:#{port}:#{sid}" @client = Sequel.connect url end ! def query sql @client.fetch(sql) end end The Sequel Way client = OracleConnection.new('...') client.query('select * from users').each do |row| # { # id: 1, # first_name: 'Harry', # last_name: 'Hurtig', # user_name: 'hhurtig', # } end
  10. None
  11. $ which java /usr/jdk/jdk1.6.0_51/bin/java ! $ wget http://jruby.org/.../jruby-bin-1.7.6.tar.gz $ tar

    zxf jruby-bin-1.7.6.tar.gz -C ~/jruby ! $ export PATH=~/jruby/bin:$PATH ! $ gem install bundler $ bundle install
  12. Other Examples

  13. None
  14. None
  15. None
  16. Conclusion • Not only GC and Native Threads • Take

    advantage of “Java is everywhere” • Embrace the JVM ecosystem
  17. Attribution • http://www.flickr.com/photos/tf28/4444660417 by TF28 ❘ tfaltings.de • http://www.flickr.com/photos/pedrosz/3993734789 by

    szeke • http://www.flickr.com/photos/nzdave/347532488 by (nz)dave • http://www.flickr.com/photos/cgranycome/9954708374 by CarolineG2011 • http://www.flickr.com/photos/digitalnc/8233509306 by North Carolina Digital Heritage Center • http://en.wikipedia.org/wiki/File:Java_virtual_machine_architecture.svg by Wikimedia Commons • http://www.flickr.com/photos/mdavidford/8650284288 by mdavidford • http://www.flickr.com/photos/apollo1981/1478327767 by apollo1981 • http://www.flickr.com/photos/yggg/287485592 by guccio@จ๪۩ࣾ • http://www.flickr.com/photos/kakutani/8281245690/ by kakutani • http://www.flickr.com/photos/barbro2009/5625148914 by Barbro_Uppsala