Jruby: Ready For Action!: Charles Oliver Nutter and Thomas Enebo
Jruby: Ready For Action!: Charles Oliver Nutter and Thomas Enebo
6
Java == A Dirty Word
• “The answer is Java. What is the
Question?”
7
Java != A Dirty Word
8
Java != A Dirty Word
• Fantastic Virtual Machine
> Tuned for over a decade by an army
> Runs on virtually all os/hardware combos
> Dynamic optimizations (Hotspot)
> Keeps getting faster:
Java 5 Java 6
Rexml 10.9s 7.41s %32
Hpricot 4.06s 2.59s %36
9
Java != A Dirty Word
• Fantastic Garbage Collectors
> Compacting
> Concurrent
> Many tunables and choices
10
Java != A Dirty Word
• Native threading
• Tools
> IDEs (refactoring, debugging)
> Profilers (instrumenting, sampling)
> JMX (ask VM for stats)
• Libraries
> Anything you can think of...
> Write image_science in 60 lines of Ruby
using Java 2D
11
Where is JRuby being used?
• Swing GUI development
> Makes Swing much nicer to use, easier
to handle
• Ruby on Rails
> Better deployment options, better
performance
• Tooling for IDEs
> JRuby's parser enables NetBeans,
Eclipse, IntelliJ
• Graphics
> Ruby + Processing = cool demos
12
Swing GUI Programming
• Swing API is very large, complex
> Ruby magic simplifies most of the tricky
bits
• Java is a very verbose language
> Ruby makes Swing actually fun
• No consistent cross-platform GUI
library for Ruby
> Swing works everywhere Java does
(everywhere)
• No fire-and-forget execution
> No dependencies: any script works on
13
Option 1: Direct approach
import javax.swing.JFrame
import javax.swing.JButton
15
Option 2: Cheri (builder approach)
include Cheri::Swing
def initialize
layout = "[<translate][*input][>result]"
@ui = Swing::LEL.new(JFrame, layout) {|cmps, ints|
cmps.translate = JButton.new("Translate")
cmps.input = JTextField.new
cmps.result = JLabel.new
18
MonkeyBars + NetBeans Matisse
19
MonkeyBars Controller
class RssController < Monkeybars::Controller
set_view "RssView"
set_model "RssModel"
close_action :exit
add_listener :type => :mouse,
:components => ["goButton", "articleList"]
23
JRuby Enables Tooling
• JRuby's parser used by most Ruby
IDEs
> NetBeans Ruby Support
> Eclipse RDT/RadRails/Aptana, DLTK, 3rd
Rail
> IntelliJ
> Jedit
• Roman Strobl's NetBeans session at
13:00
24
Graphics with Processing
• “Processing is an open source
programming language and
environment for people who want to
program images, animation, and
interactions.”
> Basically a cool Java library for 2D
graphics
• Ruby-Processing wraps Processing
with JRuby
> Cool, rubified 2D graphics environment
for you
> Eye-candy demos for us
25
DEMO
Pretty Graphics!
26
Thank you!
• Main JRuby page: www.jruby.org
• JRuby Wiki: wiki.jruby.org
• Charles Nutter
> [email protected]
> headius.blogspot.com
• Tom Enebo
> [email protected]
> www.bloglines.com/blog/ThomasEEnebo
27
JRuby:
Ready for ACTION!
●Charles Oliver Nutter and
Thomas Enebo
●The JRuby Guys
●Sun Microsystems
28