JRuby It's What's For Dinner Except where otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License (http://creativecommons.org/licenses/by-sa/3.0/us/).
Agenda Another year of JRuby The JVM: pragmatically awesome 1.9 support King Pong Best deployment evar FFI = compatible C library access All that other Java stuff Getting going, getting involved
The JRuby Guys Tom Enebo and Charles Oliver Nutter 4-6 years as JRuby devs 2 years as JRuby devs at Sun Microsystems 12+ years as Java devs Working from home (Minneapolis area) Conference junkies
Another Year of JRuby Compiler finished Fall 2007 JRuby 1.1 RC cycle Winter 2008 1.1.5 is current release (this week!) 113 bugs fixed in 1.1.5, 1552 since last year 411 revisions in 1.1.5, 3141 since last year Compatibility with 1.8.6 is “done” Performance is great, always improving 1.9 support, better Java interop on the way
The JVM: Pragmatically Awesome OpenJDK (Hotspot) Estimated 500 man-years Legendary performance, GC (“faster than C++”) Native JIT, profiled code inlining Extremely stable, secure A dynamic VM under the covers Pervasive: you all probably have it Why fight it? Why build new?
JRuby and the JVM AST (interpreter) App code Java calls JRuby Runtime Parser Ruby stdlib Compiler Core classes (String, etc) Precompiled code .class loading Bytecode Java calls
Ruby 1.9 Support Some libraries done, some coming soon Parser support “real soon now” M17N bits coming along Bytecode engine prototype (not needed?) 1.8.6 and 1.9.1 support in same binary Hasn't taken very long; done by Christmas DEMO
Use it if you choose it Java libraries can be trivially accessed A million Java libraries to choose from Ability to integrate with legacy “Java” Cross-platform solution
Demo: King Pong JMonkeyEngine: 3D Scenegraph library OpenGL, Used Commercially
Best Deployment Evar! New GlassFish gem release 0.9.0 3.9MB production web app server Single-process deployment, across cores Any web framework Simplest deployment possible: gem install glassfish glassfish <app dir> There is no step three DEMO
The Holy Grail JRuby uses real native threads Rails 2.2 “thread safety” is a big deal One JRuby instance Reduced warm-up time Reduced memory
The “Lame” Test Simple 1 controller, 1 model, 1 view app Send 1000 reqs with concurrency 10 (ab) GlassFish v2
FFI Foreign Function Interface Call C functions directly from Ruby Portable, unlike extensions Most extensions just wrap a library Started in Rubinius JRuby added support in 1.1.4 JRuby team: Ruby FFI gem gem install ffi This man did not use FFI. He wrote a C extension instead.
require 'ffi' module POSIX extend FFI::Library # not usually necessary since libc is always linked ffi_lib 'c' attach_function :getuid, :getuid, [], :uint attach_function :getpid, :getpid, [], :uint end puts "Process #{POSIX.getpid}, user #{POSIX.getuid}"
Java what? Servlets Use Rack + Warbler EE components (EJB, JMS ...) GlassFish built-in Ruby support Mobile, embedded Definitely possible; nobody working on it “Normal” Java type definition Planned; lack of class declarations complicates
Users Speak Customers already have Java App Servers Java libraries fill a void in Ruby (Swing) Cross Platform (especially Windows) Code obfuscation (AOT) Odd platform (AS400) Speed
Get Involved! www.jruby.org wiki.jruby.org #jruby on FreeNode IRC charles.nutter@sun.com, headius (Twitter) thomas.enebo@sun.com, tom_enebo (Twitter)