Archives de catégorie : ruby

Confoo 2012 : JRuby

Talk by Charles Nutter, on Friday 2nd March

How to install JRuby :

  • rvm  install jruby and unzip or
  • download tar/zip file from jruby.org or
  • you can use a windows installer from jruby.org

What is bad compared to pure Ruby ?

  • memory footprint, mostly due to the (better) GC; objects are larger, but fewer; BUT : lower memory when using concurrency (for example using rails, each http request will spawn a new Ruby process consuming the same amount of RAM, compared to JRuby  spawning some new threads and keeping its amount of RAM consumed stable and keeping barriers between those threads)
  • c extensions, still experimental

Good

  • Ruby itself (both 1.8.7 and 1.9.2. modes in the same jruby : start it with jruby –1.9)
  • sandboxed jruby (for non thread safe programs, runs in isolated mode)

JVM

  • best GC, support dynamic language
  • ruby code used with Jruby ends up in native code, optimized by the JVM
  • stable threading : jvm threads are OS threads;
  • libraries : tens of thousands of JVM library(Swing demo : Charles built a Swing panel with a button adding statements to jirb )
  • lots of tools : visualvm (demo stressed gc with old and young objects)
  • invoke dynamic : ruby is about calling methods, the jvm from 1.7 optimizes those calls

Android

  • Ruboto : gem install ruboto ; ruboto app; rake : you’re done creating an Android app with JRuby
  • Ruboto irb
  • Jruby 1.7 : invoke dynamic, dalvik enhancement, ruby 1.9 by default

Bonus

  • Charles used the redcar editor, written in jruby + swt
  • trinidad : tomcat like launcher with ruby wrapper
  • torquebox : jboss like launcher (messaging, schedulers, etc…)
  • During his Android demo, Charles used android screencast
  • warbler for war/jar : to wrap your ruby app in a war
  • you can deploy your apps to engine yard cloud