What's Different About JRuby?

       Charles Oliver Nutter
            @headius
What's Different About JRuby?

     (and why should you care?)
JRuby

Ruby on the JVM
JRuby

Started in 2001
JRuby

Fast and compatible
JRuby

Contributors all over the world
JRuby

Awesomesauce!
Install JRuby

rvm install jruby ; rvm use jruby
Install JRuby

Download tar/zip from jruby.org
      Unpack archive
       Add to PATH
Install JRuby

Windows installer at jruby.org
Get the Book
What's Different?
The Bad
Memory Footprint
Memory Footprint

  Base memory size is larger
(Footprint over time is smaller)
Memory Footprint

  Objects are larger
Memory Footprint

        Objects are larger
(But instance var table is smaller)
Missing or Disabled Features
Missing or Disabled Features

         No Kernel#fork
Missing or Disabled Features

      No continuations (callcc)
Missing or Disabled Features

      No continuations (callcc)
     (except for specific forms)
Missing or Disabled Features

     ObjectSpace off by default
         (-X+O to enable)
Missing or Disabled Features

    set_trace_func off by default
        (--debug to enable)
C Extensions

     Shipped in JRuby 1.6,
still considered experimental
The Good
Ruby Itself
Ruby Itself

Ruby 1.8.7 and 1.9.2 in the box
28
29
Ruby Itself

    Multi-VM support
(many apps in one process)
31
Ruby Itself

Solid across platforms
Ruby Itself

  Solid across platforms
(Best Ruby on Windows?)
Ruby Itself

  Solid across platforms
(Best Ruby on OpenVMS?)
Ruby Itself

 Solid across platforms
(Best Ruby on zLinux?)
Java Virtual Machine (JVM)
Java Virtual Machine (JVM)

       Java libraries like Swing
   (or Scala, Groovy, Clojure, etc)
38
39
40
41
Java Virtual Machine (JVM)

      Tools like VisualVM
43
44
45
46
47
48
49
Java Virtual Machine (JVM)

     Best garbage collectors
Java Virtual Machine (JVM)

     Optimizing JIT compiler
Java Virtual Machine (JVM)

      Concurrent threading
53
54
55
56
57
58
Java Virtual Machine (JVM)

   New dynamic dispatch support
         (invokedynamic)
60
61
Ruby = Method Calls
   Lots and lots and lots and lots...
def foo
  bar
end

def bar
  baz     foo   bar   baz
end

def baz
  # ...
end
def foo
                     JRuby on Java 5/6
  bar
end

def bar           JRuby             JRuby
  baz     foo       call    bar       call     baz
end                logic             logic
def baz
  # ...
end
                Kills many JVM optimizations
def foo
                        JRuby on Java 7
  bar




                  X X
end

def bar             JRuby             JRuby
  baz     foo         call    bar       call    baz
end                  logic             logic
def baz
  # ...
end
                Dynamic call logic built into JVM
def foo
                      JRuby on Java 7
  bar
end

def bar
  baz     foo               bar                  baz
end

def baz
  # ...
end
                Straight through dispatch path
def foo
                      JRuby on Java 7
  bar
end

def bar
  baz           foo       bar       baz
end

def baz
  # ...
end
          Optimizations (like inlining) can happen!
Benchmarks!
You know you love them.
A “Better” fib bench
   bench_fib_complex.rb 5 35
“Richards”
bench_richards.rb 1000000
Red/Black Tree
 github.com/headius/redblack
Wait for it...
    Benchmarks are benchmarks.
If you don’t like them, give us yours!
App Development
App Development

Trinidad for command-line server
       gem install trinidad
App Development

Torquebox for "Enterprise"
App Development

Warbler for WAR/JAR files
   gem install warbler
App Development

      Engine Yard AppCloud
engineyard.com/products/appcloud
App Development

Other Java servers using Warbler
What It Means For You
What It Means For You

  Faster Ruby applications
What It Means For You

   Better tool ecosystem
What It Means For You

   Solid concurrent servers
What It Means For You

  A better Ruby experience!
Thank You!

Charles Oliver Nutter
     @headius

JRuby: What's Different (RORO Melbourne October 2011)