SlideShare a Scribd company logo
1 of 32
Download to read offline
JRuby
    Enterprise 2.0



James Crisp   Josh Price

    ThoughtWorks
Agenda

• What are Ruby and JRuby?
• Benefits and Drawbacks
• Where to use?
• Demos
• Case studies
Ruby
• Created by Yukihiro Matsumoto in 1993
• Open Source
• Vibrant community
• Dynamically typed
• Pure OO
• Syntactically flexible for DSLs
• Advanced meta programming
Ruby Runtimes
•   MRI Matz’s Ruby Interpreter in C (Ruby 1.8.6)

•   YARV Yet another Ruby VM (Ruby 1.9)

•   IronRuby .NET, DLR (alpha)

•   Rubinius Alternative VM

•   xRuby Compiler in Java

•   JRuby on the JVM
Java platform
Today’s Java Platform
JRuby

•   Java implementation of Ruby

•   Open Source

•   Full time developers from Sun and ThoughtWorks
    •   Charles Nutter, Thomas Enebo, Ola Bini et al

•   Allows Ruby to call Java code and vice versa
Timeline

•   Started around 2001 by Jan Arne Petersen

•   JRuby 1.0 released in June 2007

•   JRuby 1.1 RC2 just released

•   1.1 release out soon
Why JRuby?

•   Ruby / Rails productivity & tools
•   Java libraries and interoperability
•   Run on any OS / JVM / App server
•   Leverage existing infrastructure & ops skills
•   Politics – it's just a WAR
JRuby advantages

•   Native vs Green Threading
•   World class garbage collection
•   Unicode
•   Runs the same on all platforms
•   JIT & AOT compilation
JRuby disadvantages

• Large memory footprint
• Longer startup times
• No native C extensions
• Not technically complete
Ruby Demo
A Simple Ruby Class
class RubyDemo < Demo

   def say_hello

   
   5.times { puts “Hi from Ruby!” }

   end

   def greet(guests)

   
   guests.collect { |g| “Welcome #{g.name}” }

   end
end

>> RubyDemo.new.greet(josh, james)

=> [“Welcome Josh”, “Welcome James”]
Swing Demo
import javax.swing.JFrame
import javax.swing.JButton


f = JFrame.new('Swing Demo')
f.set_size 300, 300
f.layout = java.awt.FlowLayout.new
button = JButton.new('Hi World!')
f.add(button)
f.show
Cheri Swing Demo
require 'cheri/swing'
include Cheri::Swing
f = swing.frame('Hello') {

 size 500, 500

 flow_layout

 button('Hello!') {

 
 on_click { puts 'Hi from Swing!' }

 }
}
Rails
•   Originally written by DHH extracted from Basecamp
•   Released as Open Source in 2004
•   Complete web framework:
    •   MVC framework with built-in REST / AJAX support

    •   O-R mapping framework

    •   Standard directory structure

    •   Simple templating language for views

    •   Plug-in framework
JRuby on Rails demo
• GoldSpike
 •   Packages a WAR for any Java app server

 •   Automatically creates extra runtimes

• Warbler
 •   Easy to use wrapper around GoldSpike

• Glassfish Rails gem
 •   Gem containing Glassfish v3 and Grizzly
Where to use?

• Enterprise Glue
• Web 1.0 / 2.0 Apps
• Ruby tools for Java
JRuby as
      Enterprise Glue
• Aggregating, synchronising and displaying
  data from different systems
• Productivity benefits of using Ruby / Rails
• Leverage existing Java code
• Better JMS integration
• Best of both worlds
Case Study
•   Enterprise glue in a large investment bank

•   Different systems with partial information

•   JRuby webapp aggregates and displays data

•   Built in 4 months

•   Connects to different systems
      JDBC (Sybase, Oracle)
      XML over HTTPS (Ruby + Java)
      REST over HTTPS (Ruby + Java)
      SOAP (xFire)
Mingle
•   ThoughtWorks Studios first product
•   Agile Project Management application
•   Built with Ruby on Rails, deployed on JRuby
•   v1.0 built in < 1 year
•   v1.1 released 3 months later
•   v2.0 due for release soon
JRuby and Mingle
•   Developed in MRI deployed on JRuby

•   Stable deployment

•   Speed of development

•   Java libraries
    •   charting, search, PDF, encryption

•   Obfuscating ruby code

•   Large memory footprint / speed
Ruby Tools
• Gems package management
 • Simple
     gem install activescaffold
• Rake tool
 • Build
     rake db:migrate
• Capistrano
 • Flexible deployment tool
     cap production deploy
Rake
desc “Generate application code”
task :code_gen do
 # do the code generation
end

desc “Compile code”
task :compile => [:code_gen] do
 #do the compilation
end

desc “Test application”
task :test => [:compile] do
 # run the tests
end
Capistrano
desc quot;Start ferret serverquot;
task :start, :role => :app do
  run quot;cd #{current_path}; script/ferret_server -e #{stage} startquot;
end

desc quot;Stop ferret serverquot;
task :stop, :role => :app do
  run quot;cd #{current_path}; script/ferret_server -e #{stage} stopquot;
end

desc quot;Restart ferret serverquot;
task :restart, :role => :app do
  ferret.server.stop
  sleep(5)
  ferret.server.start
end
Unit test Java code
require 'test/unit'
require 'java'

import java.util.ArrayList

class ArrayListTest < Test::Unit::TestCase

 def test_adding_object_to_arraylist
  list = ArrayList.new
  list.add(“element”)
  assert_equal(1, list.size)
 end

end
RSpec Java code
require 'spec'
require 'java'

import java.util.ArrayList

describe quot;ArrayList with no elementsquot; do

 it quot;should have one element after adding a stringquot; do
   list = ArrayList.new
   list.add(“element”)
   list.size.should == 1
 end

end
Adoption issues

• Few developers in the market
• Smaller community than Ruby or Java
• Less books, google hits, documentation
• Less training and support options
• Diverging from the “one true language”
Adoption

 •   Ola's book
 •   Growing community
 •   Mailing lists & blogs
Summary
• Ruby / Rails productivity
• Web apps and system integration
• Leverage your Java investment
• Deploy to mature Java production
  environment
• Already used in production
Questions?
References
JRuby
  
   http://www.jruby.org
Ola Bini's blog & book
      http://ola-bini.blogspot.com/
Charles Nutter's blog
  
   http://headius.blogspot.com/
James' blog (for slides)
  
   http://jamescrisp.org/

More Related Content

What's hot

Node.js in a heterogeneous system
Node.js in a heterogeneous systemNode.js in a heterogeneous system
Node.js in a heterogeneous system
GeeksLab Odessa
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
Jesse Warden
 

What's hot (20)

JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
Node.js in a heterogeneous system
Node.js in a heterogeneous systemNode.js in a heterogeneous system
Node.js in a heterogeneous system
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web Development
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricks
 
NodeJS: n00b no more
NodeJS: n00b no moreNodeJS: n00b no more
NodeJS: n00b no more
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Kraken js at paypal
Kraken js at paypalKraken js at paypal
Kraken js at paypal
 
Javascript Bundling and modularization
Javascript Bundling and modularizationJavascript Bundling and modularization
Javascript Bundling and modularization
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
 
Taming AEM deployments
Taming AEM deploymentsTaming AEM deployments
Taming AEM deployments
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
System webpack-jspm
System webpack-jspmSystem webpack-jspm
System webpack-jspm
 
TorqueBox for Rubyists
TorqueBox for RubyistsTorqueBox for Rubyists
TorqueBox for Rubyists
 
Gearman and CodeIgniter
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniter
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 

Viewers also liked (7)

Desastre Natural
Desastre NaturalDesastre Natural
Desastre Natural
 
Web 2.0 in the classroom
Web 2.0 in the classroomWeb 2.0 in the classroom
Web 2.0 in the classroom
 
Personal Learning Networks
Personal Learning NetworksPersonal Learning Networks
Personal Learning Networks
 
Já Aconteceu!!!!
Já Aconteceu!!!!Já Aconteceu!!!!
Já Aconteceu!!!!
 
Personal Learning Networks
Personal Learning NetworksPersonal Learning Networks
Personal Learning Networks
 
Fds N25 29 Fev2008
Fds N25 29 Fev2008Fds N25 29 Fev2008
Fds N25 29 Fev2008
 
CCSD Wando Middle College storyboard
CCSD Wando Middle College storyboardCCSD Wando Middle College storyboard
CCSD Wando Middle College storyboard
 

Similar to JRuby - Enterprise 2.0

JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
elliando dias
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
Keith Bennett
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
QConLondon2008
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
deimos
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Kyle Drake
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
Amit Solanki
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
oscon2007
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
Spike Brehm
 

Similar to JRuby - Enterprise 2.0 (20)

Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of Ruby
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 

More from Jan Sifra

Marketing na internete berú firmy vážne
Marketing na internete berú firmy vážneMarketing na internete berú firmy vážne
Marketing na internete berú firmy vážne
Jan Sifra
 
15 vecí, ktoré som mal vedieť ako študent marketingu
15 vecí, ktoré som mal vedieť ako študent marketingu15 vecí, ktoré som mal vedieť ako študent marketingu
15 vecí, ktoré som mal vedieť ako študent marketingu
Jan Sifra
 
Baťa brožúra z 30. rokov
Baťa brožúra z 30. rokovBaťa brožúra z 30. rokov
Baťa brožúra z 30. rokov
Jan Sifra
 
Time manažment ohlupovacou metódou
Time manažment ohlupovacou metódouTime manažment ohlupovacou metódou
Time manažment ohlupovacou metódou
Jan Sifra
 
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
Jan Sifra
 
Etarget Partner programme - Bulgaria
Etarget Partner programme - BulgariaEtarget Partner programme - Bulgaria
Etarget Partner programme - Bulgaria
Jan Sifra
 
Strategie Social Net
Strategie Social NetStrategie Social Net
Strategie Social Net
Jan Sifra
 
Nokia for Business
Nokia for BusinessNokia for Business
Nokia for Business
Jan Sifra
 
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync softwareJak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
Jan Sifra
 
Nasazení mobilních technologií v českých podnicích
Nasazení mobilních technologií v českých podnicích Nasazení mobilních technologií v českých podnicích
Nasazení mobilních technologií v českých podnicích
Jan Sifra
 
Koppl Internet
Koppl InternetKoppl Internet
Koppl Internet
Jan Sifra
 
Advertising Exchanges - Open the market!
Advertising Exchanges - Open the market!Advertising Exchanges - Open the market!
Advertising Exchanges - Open the market!
Jan Sifra
 
Reality Mining (Nathan Eagle)
Reality Mining (Nathan Eagle)Reality Mining (Nathan Eagle)
Reality Mining (Nathan Eagle)
Jan Sifra
 
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspaceI'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
Jan Sifra
 

More from Jan Sifra (20)

Marketing na internete berú firmy vážne
Marketing na internete berú firmy vážneMarketing na internete berú firmy vážne
Marketing na internete berú firmy vážne
 
Pátranie po reklamnej agentúre Tomáša Baťu
Pátranie po reklamnej agentúre Tomáša BaťuPátranie po reklamnej agentúre Tomáša Baťu
Pátranie po reklamnej agentúre Tomáša Baťu
 
15 vecí, ktoré som mal vedieť ako študent marketingu
15 vecí, ktoré som mal vedieť ako študent marketingu15 vecí, ktoré som mal vedieť ako študent marketingu
15 vecí, ktoré som mal vedieť ako študent marketingu
 
Baťa brožúra z 30. rokov
Baťa brožúra z 30. rokovBaťa brožúra z 30. rokov
Baťa brožúra z 30. rokov
 
Time manažment ohlupovacou metódou
Time manažment ohlupovacou metódouTime manažment ohlupovacou metódou
Time manažment ohlupovacou metódou
 
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
15 vecí, ktoré by ste mali vedieť o písaní reklamných titulkov pre web
 
Etarget Partner programme - Bulgaria
Etarget Partner programme - BulgariaEtarget Partner programme - Bulgaria
Etarget Partner programme - Bulgaria
 
3 lessons science can teach you about internet marketing
3 lessons science can teach you about internet marketing3 lessons science can teach you about internet marketing
3 lessons science can teach you about internet marketing
 
Strategie Social Net
Strategie Social NetStrategie Social Net
Strategie Social Net
 
Nokia for Business
Nokia for BusinessNokia for Business
Nokia for Business
 
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync softwareJak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
Jak zvýšit mobilitu firemních pracovníků - Mobile Nokia Intellisync software
 
Nasazení mobilních technologií v českých podnicích
Nasazení mobilních technologií v českých podnicích Nasazení mobilních technologií v českých podnicích
Nasazení mobilních technologií v českých podnicích
 
Koppl Internet
Koppl InternetKoppl Internet
Koppl Internet
 
How to keep sales up with Etarget
How to keep sales up with EtargetHow to keep sales up with Etarget
How to keep sales up with Etarget
 
Advertising Exchanges - Open the market!
Advertising Exchanges - Open the market!Advertising Exchanges - Open the market!
Advertising Exchanges - Open the market!
 
Futurad Case Studies
Futurad Case StudiesFuturad Case Studies
Futurad Case Studies
 
Reality Mining (Nathan Eagle)
Reality Mining (Nathan Eagle)Reality Mining (Nathan Eagle)
Reality Mining (Nathan Eagle)
 
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspaceI'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
I'm sorry Jaiku, I have been drunk since Thursday. Pictures on myspace
 
Dnes k vam pride navsteva
Dnes k vam pride navstevaDnes k vam pride navsteva
Dnes k vam pride navsteva
 
Serban Alexandrescu
Serban AlexandrescuSerban Alexandrescu
Serban Alexandrescu
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

JRuby - Enterprise 2.0

  • 1. JRuby Enterprise 2.0 James Crisp Josh Price ThoughtWorks
  • 2. Agenda • What are Ruby and JRuby? • Benefits and Drawbacks • Where to use? • Demos • Case studies
  • 3. Ruby • Created by Yukihiro Matsumoto in 1993 • Open Source • Vibrant community • Dynamically typed • Pure OO • Syntactically flexible for DSLs • Advanced meta programming
  • 4. Ruby Runtimes • MRI Matz’s Ruby Interpreter in C (Ruby 1.8.6) • YARV Yet another Ruby VM (Ruby 1.9) • IronRuby .NET, DLR (alpha) • Rubinius Alternative VM • xRuby Compiler in Java • JRuby on the JVM
  • 7. JRuby • Java implementation of Ruby • Open Source • Full time developers from Sun and ThoughtWorks • Charles Nutter, Thomas Enebo, Ola Bini et al • Allows Ruby to call Java code and vice versa
  • 8. Timeline • Started around 2001 by Jan Arne Petersen • JRuby 1.0 released in June 2007 • JRuby 1.1 RC2 just released • 1.1 release out soon
  • 9. Why JRuby? • Ruby / Rails productivity & tools • Java libraries and interoperability • Run on any OS / JVM / App server • Leverage existing infrastructure & ops skills • Politics – it's just a WAR
  • 10. JRuby advantages • Native vs Green Threading • World class garbage collection • Unicode • Runs the same on all platforms • JIT & AOT compilation
  • 11. JRuby disadvantages • Large memory footprint • Longer startup times • No native C extensions • Not technically complete
  • 13. A Simple Ruby Class class RubyDemo < Demo def say_hello 5.times { puts “Hi from Ruby!” } end def greet(guests) guests.collect { |g| “Welcome #{g.name}” } end end >> RubyDemo.new.greet(josh, james) => [“Welcome Josh”, “Welcome James”]
  • 14. Swing Demo import javax.swing.JFrame import javax.swing.JButton f = JFrame.new('Swing Demo') f.set_size 300, 300 f.layout = java.awt.FlowLayout.new button = JButton.new('Hi World!') f.add(button) f.show
  • 15. Cheri Swing Demo require 'cheri/swing' include Cheri::Swing f = swing.frame('Hello') { size 500, 500 flow_layout button('Hello!') { on_click { puts 'Hi from Swing!' } } }
  • 16. Rails • Originally written by DHH extracted from Basecamp • Released as Open Source in 2004 • Complete web framework: • MVC framework with built-in REST / AJAX support • O-R mapping framework • Standard directory structure • Simple templating language for views • Plug-in framework
  • 17. JRuby on Rails demo • GoldSpike • Packages a WAR for any Java app server • Automatically creates extra runtimes • Warbler • Easy to use wrapper around GoldSpike • Glassfish Rails gem • Gem containing Glassfish v3 and Grizzly
  • 18. Where to use? • Enterprise Glue • Web 1.0 / 2.0 Apps • Ruby tools for Java
  • 19. JRuby as Enterprise Glue • Aggregating, synchronising and displaying data from different systems • Productivity benefits of using Ruby / Rails • Leverage existing Java code • Better JMS integration • Best of both worlds
  • 20. Case Study • Enterprise glue in a large investment bank • Different systems with partial information • JRuby webapp aggregates and displays data • Built in 4 months • Connects to different systems JDBC (Sybase, Oracle) XML over HTTPS (Ruby + Java) REST over HTTPS (Ruby + Java) SOAP (xFire)
  • 21. Mingle • ThoughtWorks Studios first product • Agile Project Management application • Built with Ruby on Rails, deployed on JRuby • v1.0 built in < 1 year • v1.1 released 3 months later • v2.0 due for release soon
  • 22. JRuby and Mingle • Developed in MRI deployed on JRuby • Stable deployment • Speed of development • Java libraries • charting, search, PDF, encryption • Obfuscating ruby code • Large memory footprint / speed
  • 23. Ruby Tools • Gems package management • Simple gem install activescaffold • Rake tool • Build rake db:migrate • Capistrano • Flexible deployment tool cap production deploy
  • 24. Rake desc “Generate application code” task :code_gen do # do the code generation end desc “Compile code” task :compile => [:code_gen] do #do the compilation end desc “Test application” task :test => [:compile] do # run the tests end
  • 25. Capistrano desc quot;Start ferret serverquot; task :start, :role => :app do run quot;cd #{current_path}; script/ferret_server -e #{stage} startquot; end desc quot;Stop ferret serverquot; task :stop, :role => :app do run quot;cd #{current_path}; script/ferret_server -e #{stage} stopquot; end desc quot;Restart ferret serverquot; task :restart, :role => :app do ferret.server.stop sleep(5) ferret.server.start end
  • 26. Unit test Java code require 'test/unit' require 'java' import java.util.ArrayList class ArrayListTest < Test::Unit::TestCase def test_adding_object_to_arraylist list = ArrayList.new list.add(“element”) assert_equal(1, list.size) end end
  • 27. RSpec Java code require 'spec' require 'java' import java.util.ArrayList describe quot;ArrayList with no elementsquot; do it quot;should have one element after adding a stringquot; do list = ArrayList.new list.add(“element”) list.size.should == 1 end end
  • 28. Adoption issues • Few developers in the market • Smaller community than Ruby or Java • Less books, google hits, documentation • Less training and support options • Diverging from the “one true language”
  • 29. Adoption • Ola's book • Growing community • Mailing lists & blogs
  • 30. Summary • Ruby / Rails productivity • Web apps and system integration • Leverage your Java investment • Deploy to mature Java production environment • Already used in production
  • 32. References JRuby http://www.jruby.org Ola Bini's blog & book http://ola-bini.blogspot.com/ Charles Nutter's blog http://headius.blogspot.com/ James' blog (for slides) http://jamescrisp.org/