SlideShare a Scribd company logo
1 of 13
JRuby
              The Best of Java
                 and Ruby
                                  by
                            Evgeny Rahman




Image source: https://github.com/jruby/collateral/ by Tony Price (tonyxprice)
JRuby is Copyright (c) 2007-2012 The JRuby project
A little bit about Ruby
• Created in 1993 by Yukihiro Matsumoto
  (“Matz”).
• An object-oriented scripting language.
• Guiding philosophy - a language that feels
  natural to programmers.
• Principle of least surprise.
Adoption
• First English mailing list appeared in 1999.
• “Programming Ruby” (aka “The Pickaxe
  Book”) by Dave Thomas and Andy Hunt
  released in 2000.
• Interest grew considerably in 2005 because of
  the Rails framework.
• 225,000 Ruby projects on GitHub.
Examples
• The all-important Hello World:
    puts "Hello World"

• Array iteration:
    ['a', 'b', 'c', 'd', 'e'].each { |x| puts x }

• Hash operations:
      animal_sounds = { :dog => 'woof', :cat => 'meow'}
      animal_sounds[:dog]

      #=> 'woof'
Examples
• unless:
  "Unicorns exist!" unless unicorns.empty?

• Blocks:
  flights = flights.sort do |flight_a, flight_b|
      flight_a.price <=> flight_b.price
  end

• Loops:
  100.times { |i| puts "The number is #{i}" }
JRuby
•   Created by Jan Arne Petersen in 2001.
•   Ruby implementation that runs on the JVM.
•   Current core team of nine developers.
•   Currently 1.7.0 is out in preview.
•   Supports MRI 1.8.7 and 1.9.3.
•   Code is JIT and AOT compiled into JVM
    bytecode.
Advantages
• Java interop – use the Java ecosystem and
  your existing libraries.
• Threading – real, JVM multithreading.
• InvokeDynamic in Java 7 – optimization in
  performance for JRuby.
• Deployment – several options, including
  familiar, Java ones.
Java interop – simple!
require 'java'
java_import 'java.lang.Math'

puts java.lang.Math::PI
 #=> 3.14159265358979
Java interop – libraries
      require 'java‘
      require 'path/to/yourlib.jar'


 Now if you do:
      java_import "org.your.lib.YourClass"


 Your class is available as
     Java-style:     org.your.lib.YourClass
     Ruby-style:   Java::YourLib::YourClass


 and directly referenced as
     YourClass


More information: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
Caveats
• Gems with C extensions – use alternatives.
• JVM startup time – TDD, scripting.
• No compilation – more testing, more
  discipline.
• Development-Deployment gap.
Deployment
•   This was the missing link for Ruby in the enterprise *
•   Warbler – create a WAR and deploy it to a Java EE container.
•   jet.pack – package your JRuby rack app for Jetty.
•   Trinidad – run Rails or Rack applications on embedded Tomcat container.
•   Mizuno – jetty-powered server for JRuby in the style of Thin or WEBRick
•   Torquebox – JBoss AS-based Ruby application platform
     • Rack (Rails, Sinatra), JDBC, Daemons, Scheduled Jobs, Messaging,
       Asynchronous Tasks
• “Deploying with JRuby” – Joe Kutner, The Pragmatic Bookshelf.




* My humble opinion
Community
• Really nice people!
• Core team is great, but there are also many
  other contributors.
• Blogs, Twitter, IRC, Mailing Lists, Wiki, Issue
  tracker.
• JRubyConf organized every year since 2009 –
  this year’s was in Minneapolis, MN.
• Best place to start: jruby.org
Resources
• http://jruby.org/
• http://github.com/jruby/ - GitHub
• http://jira.codehaus.org/browse/JRUBY - issue
  tracker
• http://kenai.com/projects/jruby/pages/Home -
  old wiki
• https://github.com/jruby/jruby/wiki/ - new wiki
• #jruby IRC channel on FreeNode IRC
• @jruby on Twitter

More Related Content

What's hot

What's hot (11)

High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013High Performance Ruby - E4E Conference 2013
High Performance Ruby - E4E Conference 2013
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 
Ruby+rails
Ruby+railsRuby+rails
Ruby+rails
 
Oscon 2010
Oscon 2010Oscon 2010
Oscon 2010
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
JRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVMJRuby 9000 - Optimizing Above the JVM
JRuby 9000 - Optimizing Above the JVM
 
Ruby Midwest 2010 jRuby by Charles Nutter
Ruby Midwest 2010 jRuby by Charles NutterRuby Midwest 2010 jRuby by Charles Nutter
Ruby Midwest 2010 jRuby by Charles Nutter
 
From 'Legacy' to 'Edge'
From 'Legacy' to 'Edge'From 'Legacy' to 'Edge'
From 'Legacy' to 'Edge'
 
Smalltalk in the pocket - Building applications for the iPhone
Smalltalk in the pocket - Building applications for the iPhoneSmalltalk in the pocket - Building applications for the iPhone
Smalltalk in the pocket - Building applications for the iPhone
 
Jvm2
Jvm2Jvm2
Jvm2
 

Similar to JRuby - The Best of Java and Ruby

Javantura 2014 - Java 8 JavaScript Nashorn
Javantura 2014 - Java 8 JavaScript NashornJavantura 2014 - Java 8 JavaScript Nashorn
Javantura 2014 - Java 8 JavaScript Nashorn
Miroslav Resetar
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
elliando dias
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 

Similar to JRuby - The Best of Java and Ruby (20)

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 
Javantura Zagreb 2014 - Nashorn - Miroslav Rešetar
Javantura Zagreb 2014 - Nashorn - Miroslav RešetarJavantura Zagreb 2014 - Nashorn - Miroslav Rešetar
Javantura Zagreb 2014 - Nashorn - Miroslav Rešetar
 
Javantura 2014 - Java 8 JavaScript Nashorn
Javantura 2014 - Java 8 JavaScript NashornJavantura 2014 - Java 8 JavaScript Nashorn
Javantura 2014 - Java 8 JavaScript Nashorn
 
TSSJS 2011 - JRuby
TSSJS 2011 - JRubyTSSJS 2011 - JRuby
TSSJS 2011 - JRuby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Jax keynote
Jax keynoteJax keynote
Jax keynote
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
10 Things you should know about Ruby
10 Things you should know about Ruby10 Things you should know about Ruby
10 Things you should know about Ruby
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
JRuby in The Enterprise
JRuby in The EnterpriseJRuby in The Enterprise
JRuby in The Enterprise
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 

Recently uploaded

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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?
 
[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
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

JRuby - The Best of Java and Ruby

  • 1. JRuby The Best of Java and Ruby by Evgeny Rahman Image source: https://github.com/jruby/collateral/ by Tony Price (tonyxprice) JRuby is Copyright (c) 2007-2012 The JRuby project
  • 2. A little bit about Ruby • Created in 1993 by Yukihiro Matsumoto (“Matz”). • An object-oriented scripting language. • Guiding philosophy - a language that feels natural to programmers. • Principle of least surprise.
  • 3. Adoption • First English mailing list appeared in 1999. • “Programming Ruby” (aka “The Pickaxe Book”) by Dave Thomas and Andy Hunt released in 2000. • Interest grew considerably in 2005 because of the Rails framework. • 225,000 Ruby projects on GitHub.
  • 4. Examples • The all-important Hello World: puts "Hello World" • Array iteration: ['a', 'b', 'c', 'd', 'e'].each { |x| puts x } • Hash operations: animal_sounds = { :dog => 'woof', :cat => 'meow'} animal_sounds[:dog] #=> 'woof'
  • 5. Examples • unless: "Unicorns exist!" unless unicorns.empty? • Blocks: flights = flights.sort do |flight_a, flight_b| flight_a.price <=> flight_b.price end • Loops: 100.times { |i| puts "The number is #{i}" }
  • 6. JRuby • Created by Jan Arne Petersen in 2001. • Ruby implementation that runs on the JVM. • Current core team of nine developers. • Currently 1.7.0 is out in preview. • Supports MRI 1.8.7 and 1.9.3. • Code is JIT and AOT compiled into JVM bytecode.
  • 7. Advantages • Java interop – use the Java ecosystem and your existing libraries. • Threading – real, JVM multithreading. • InvokeDynamic in Java 7 – optimization in performance for JRuby. • Deployment – several options, including familiar, Java ones.
  • 8. Java interop – simple! require 'java' java_import 'java.lang.Math' puts java.lang.Math::PI #=> 3.14159265358979
  • 9. Java interop – libraries require 'java‘ require 'path/to/yourlib.jar' Now if you do: java_import "org.your.lib.YourClass" Your class is available as Java-style: org.your.lib.YourClass Ruby-style: Java::YourLib::YourClass and directly referenced as YourClass More information: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
  • 10. Caveats • Gems with C extensions – use alternatives. • JVM startup time – TDD, scripting. • No compilation – more testing, more discipline. • Development-Deployment gap.
  • 11. Deployment • This was the missing link for Ruby in the enterprise * • Warbler – create a WAR and deploy it to a Java EE container. • jet.pack – package your JRuby rack app for Jetty. • Trinidad – run Rails or Rack applications on embedded Tomcat container. • Mizuno – jetty-powered server for JRuby in the style of Thin or WEBRick • Torquebox – JBoss AS-based Ruby application platform • Rack (Rails, Sinatra), JDBC, Daemons, Scheduled Jobs, Messaging, Asynchronous Tasks • “Deploying with JRuby” – Joe Kutner, The Pragmatic Bookshelf. * My humble opinion
  • 12. Community • Really nice people! • Core team is great, but there are also many other contributors. • Blogs, Twitter, IRC, Mailing Lists, Wiki, Issue tracker. • JRubyConf organized every year since 2009 – this year’s was in Minneapolis, MN. • Best place to start: jruby.org
  • 13. Resources • http://jruby.org/ • http://github.com/jruby/ - GitHub • http://jira.codehaus.org/browse/JRUBY - issue tracker • http://kenai.com/projects/jruby/pages/Home - old wiki • https://github.com/jruby/jruby/wiki/ - new wiki • #jruby IRC channel on FreeNode IRC • @jruby on Twitter