Java is a 10+ year old programming language
Java is the new COBOL
Java is Dead
Long live Java!
Java is not going anywhere
Because Java is everywhere!
But Java is not perfect
and it is adjusting to keep up
Java has its jewels
JDBC, JMS, Servlets
and its blemishes...
EJB < 3, JSF
But we have a secret weapon...
On this corner...
presenting the amazing, highly tuned, multi-
platform computing engine that dominates the
present and permeates the future
The JVM
The are more than 200+ languages implementations
for the Java VM
The Java VM is like that neighborhood with low taxes
and good schools... everyone wants in
Regardless of where we go with Java “the language”,
Java “the platform” is here to stay
Groovy, JRuby and all the new kids on the block are
just new additions to our beloved Swiss army knife
Java is solid on the server-side
Java powers the enterprise
Web development with Java has not been all that
successful in the presentation tier
Dynamic languages and frameworks based on dynamic
languages have proved to be better suited for this
Created by Yukihiro “Matz” Matsumoto
Developed in 1993, released in 1995
Blended parts of his favorite languages:
Perl, Smalltalk, Sather, Eiffel, CLU, Ada and Lisp
More popular than Python in Japan
Ruby Ideals:
Programming should be fun!
Principle of Least Surprise
“I believe people want to express themselves when
they program. They don’t want to fight with the
language. Programming languages must feel natural
to programmers.”
Matz
Ruby libraries from Java (like ActiveRecord)
➡Using Bean Scripting Framework (JDK <= 1.5)
➡Using JSR 223 Scripting API (JDK > 1.5)
Java libraries from Ruby (Swing, SWT)
RubyGems comes pre-installed
Mongrel supports JRuby
Rails just works
No native extensions (unless by native you mean Java ;-)
JRuby does not produce bytecode artifacts for
the Ruby code (yet!)
This is key difference with Groovy*
Corporate backing :-) Sun and Thoughtworks
have folks working on JRuby full-time
Let’s try some interactive JRuby
Fire up the JRuby console using Java Web Start
http://www.tc.umn.edu/%7Eenebo/webstart/jirb-console/console.jnlp
Java version of IRB (Interactive RuBy) tool
package com.integrallis;
import java.io.BufferedReader; Let’s open the text file
import java.io.FileReader;
import java.io.IOException; and print out its contents
public class MyFileReader { ...in Java
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new FileReader(quot;read_me.txtquot;));
String str;
while ((str = in.readLine()) != null) {
System.out.println(str);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
For Web applications...
Best of both worlds:
➡Dynamic-Framework on the Front End (Rails)
➡Solid Back End battle tested technologies (Spring/EJB3)
Got API-itis?
Ruby’s ability to create concise DSLs
paired with Java’s richness of APIs and frameworks
Java APIs are robust, fully-featured, flexible...
...which makes them complex
A JRuby DSL can help us in the 80-20 scenarios
There are JRuby DSLs all ready to use...
Today!
ActiveRecord-JDBC - OR-Wrapping
Raven - Wrapper for Rake, RubyGems and Maven
AntBuilder - Wrapper for Ant
JRake - Wrapper for Rake
JtestR - Test Java code with the best Ruby testing tools
Java & JEE
the most prevalent language
the most complete enterprise platform
a rich ecosystem of web frameworks
a vibrant open source community
Java & JEE
plagued by mediocre web frameworks
not well suited for rapid prototyping
in need of a dynamic language web framework
one level of abstraction too low for the web
JRuby on Rails
JEE servers are good at scaling up
no more multi-process management
use JRuby “multi-VM” support
leverage the maturity of the JVM and JEE servers
JRuby on Rails
deploy your Rails app as a WAR
leverage JDBC from ActiveRecord
JRuby+Spring RAD
a simple example by the folks at jobster
use JRuby for rapid prototyping
Spring controller that delegates to a JRuby controller
JRuby controllers live alongside your JSPs
JRoR on Spring
Chris Nelson’s work
✓use rails-integration plugin
✓ expose WebApplicationContext in a RoR controller
✓include Spring - Spring plugin for JRuby
JRoR on Spring
✓install goldspike rails-integration plugin on you JRoR app
✓ rake war:standalone:create to package a WAR with:
➡Your RoR app
➡JRuby and Rails libraries
JRoR on Spring
✓add a new face to your Spring applications
✓ leverage thousands of open source projects
✓leverage the good parts of JEE like JDBC and JMS
Resources
JRuby
www.jruby.org
rubyforge.org/projects/jruby-extras
JRuby Rails Integration
www.headius.com/jrubywiki/index.php/Rails_Integration
headius.blogspot.com/2006/11/advanced-rails-deployment-with-jruby.html
RAD Spring Prototyping with JRuby
thebogles.com/blog/projects/ruby-on-spring/
www.botspiritcompany.com/src/springruby/example_ruby_spring.html
Chris Nelson’s Work
mysterycoder.blogspot.com/2007/06/spring-jruby.html
mysterycoder.blogspot.com/2007/06/include-spring.html