• Save
JRuby - The Best of Java and Ruby
Upcoming SlideShare
Loading in...5
×
 

JRuby - The Best of Java and Ruby

on

  • 704 views

 

Statistics

Views

Total Views
704
Views on SlideShare
704
Embed Views
0

Actions

Likes
2
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

JRuby - The Best of Java and Ruby JRuby - The Best of Java and Ruby Presentation Transcript

  • JRuby The Best of Java and Ruby by Evgeny RahmanImage 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 javajava_import java.lang.Mathputs 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 YourClassMore 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