- JRuby
Infobox Software
name = JRuby
caption =
developer = Charles Nutter, Thomas Enebo, Ola Bini and Nick Sieger
latest release version = 1.1.4
latest release date = release date|2008|08|28
latest preview version =
latest preview date =
operating system =Cross-platform
platform =Java Virtual Machine
programming language = Ruby and Java
genre = Ruby programming language interpreter
license = CPL/GPL/LGPL
website = http://jruby.codehaus.org/JRuby is a Java implementation of the Ruby interpreter, being developed by the JRuby team.
JRuby is
free software released under a three-way CPL/GPL/LGPL license.JRuby is tightly integrated with Java to allow the embedding of the interpreter into any Java application with full two-way access between the Java and the Ruby code. (Compare
Jython for the Python language.)JRuby's lead developers are
Charles Nutter [http://headius.blogspot.com/] ,Thomas Enebo [http://www.bloglines.com/blog/ThomasEEnebo]Ola Bini [http://ola-bini.blogspot.com/] andNick Sieger [http://blog.nicksieger.com/] . In September 2006,Sun Microsystems hired Enebo and Nutter to work on JRuby full time. [cite web|url=http://blogs.sun.com/ontherecord/entry/sun_welcomes_jruby_developers |title=Sun Welcomes JRuby Developers |accessdate=2006-09-09 |author=Jacki |date=2006-09-07 |publisher=On the Record] In June 2007,ThoughtWorks hired Ola Bini to work on Ruby and JRuby. [cite web|url=http://ola-bini.blogspot.com/2007/03/thoughtworks.html |title=ThoughtWorks |author=Ola Bini|publisher=On the Record]History
JRuby was originally created by Jan Arne Petersen, in 2001. At that time and for several years following, the code was a direct port of the Ruby 1.6 C code. With the release of Ruby 1.8.6, an effort began to update JRuby to 1.8.6 features and semantics. Since 2001, several contributors have assisted the project, leading to the current (2008) core team of four members.
The Netbeans Ruby Pack, available since NetBeans 6.0, allows IDE development with Ruby and JRuby, as well as
Ruby on Rails for the two implementations of Ruby [http://www.netbeans.org/servlets/NewsItemView?newsItemID=1015] [http://www.infoworld.com/article/07/03/01/HNsunruby_1.html] .JRuby 1.1 added
Just-in-time compilation and Ahead-of-time compilation modes to JRuby and is faster in most cases than the current Ruby 1.8.7 reference implementationcite web
url=http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=jruby&lang2=ruby
title=JRuby performance benchmark
publisher=shootout.alioth.debian.org
date=2008-09-14
accessdate=2008-09-14] cite web
url=http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/
title=The Great Ruby Shootout
date=2007-03-12
last=Cangiano|first=Antonio
accessdate=2008-02-01] .JRuby 1.1.1 is stated to be packaged in Fedora 9 [cite web
url=http://headius.blogspot.com/2008/04/jruby-111-in-redhat-fedora.html
title=JRuby 1.1.1 in RedHat Fedora
date=2008-04-25
last=Nutter|first=Charles
accessdate=2008-04-26] [cite web
url=https://admin.fedoraproject.org/pkgdb/packages/name/jruby
title=jruby
publisher=fedoraproject.org
accessdate=2008-04-26] .Since version 1.1.1, the JRuby team began to issue point releases often to quickly address issues that are brought up by users [cite web
url=http://docs.codehaus.org/display/JRUBY/2008/07/19/JRuby+1.1.3+Released
title=JRuby 1.1.3 Released
date=2008-07-19
publisher=jruby.codehaus.org
quote="Our goal is to put out point releases more frequently for the next several months (about 3-4 weeks a release). We want a more rapid release cycle to better address issues brought up by users of JRuby."
accessdate=2008-07-19] .Rails
Multiple Virtual Machine Collaboration
On
February 27 ,2008 ,Sun Microsystems and theUniversity of Tokyo announced a joint-research project to implement a Virtual Machine capable of executing more than one Ruby or JRuby application on one interpreter [cite web
url=http://www.sun.com/aboutsun/pr/2008-02/sunflash.20080227.5.xml
title=The University of Tokyo and Sun Microsystems Commence Joint Research Projects on High Performance Computing and Web-based Programming Languages
publisher=Sun Microsystems
date=2008-02-27
accessdate=2008-02-28] .Dynamic Invocation on Java Virtual Machines
JSR 292 ("Supporting Dynamically Typed Languages on the JavaTM Platform") [ [http://www.jcp.org/en/jsr/detail?id=292 see JSR 292] ] propose to:
* add a newinvokedynamic
instruction at the JVM level, to allow method invocation relying on dynamic Type checking,
* to be able to change the classes and method at runtime dynamically in a production environment.The Sun Open source project Multi Language Virtual Machine aim to prototype this JSR [cite web
url=http://openjdk.java.net/projects/mlvm/subprojects.html
title=Sub-Projects and Investigations
date=2007
publisher=Sun Microsystems
accessdate=2008-02-06] . The first working prototype, developed as a patch onOpenJDK , was announced and made available on end of August 2008 [cite web
url=http://blogs.sun.com/jrose/entry/international_invokedynamic_day
date=2008-08-26
title=Happy International Invokedynamic Day!
last=Rose|first=John
accessdate=2008-09-03] [cite web
url=http://www.infoq.com/news/2008/09/invokedynamic_day
title=Dynamic Invocation Runs on OpenJDK
last=Lorimer|first=R.J.
publisher=infoq.com
date=2008-09-01
accessdate=2008-09-03] .The JRuby team has successfully wired dynamic invocation in their codebase, albeit in a very primitive way. Dynamic invocation will ship with the next 1.1.5 release, and will be disabled on JVMs without Dynamic invocation capabilities [cite web
url=http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html
title=A First Taste of InvokeDynamic
last=Nutter|first=Charles
quote="I managed to successfully wire InvokeDynamic directly into JRuby's dispatch process! Such excitement! The code is already in JRuby's trunk, and will ship with JRuby 1.1.5 (though it obviously will be disabled on JVMs without InvokeDynamic)."
date=2008-09-11
accessdate=2008-09-13] .Design
Since early 2006, the current JRuby core team has endeavored to move JRuby beyond being a simple C port, to support better performance and to aid eventual compilation to Java bytecode. To support this end, the team set an ambitious goal: to be able to run
Ruby on Rails unmodified using JRuby. In the process of achieving this goal, the JRuby test suite expanded to such extent that the team gained confidence in the "correctness" of JRuby. As a result, toward the end of 2006 and in the beginning of 2007, they began to commit much more complicated redesigns and refactorings of JRuby's core subsystems.JRuby is designed to work as a mixed-mode virtual machine for Ruby, where code can be either interpreted directly, just-in-time compiled at runtime to Java bytecode, or ahead-of-time compiled to Java bytecode before execution. Until October 2007, only the interpreted mode supported all Ruby's constructs, but a full AOT/JIT compiler is available since version 1.1cite web
url=http://headius.blogspot.com/2007/09/compiler-is-complete.html
title=The Compiler Is Complete
date=2007-09-27
last=Nutter|first=Charles
accessdate=2007-10-12] . The compiler design allows for interpreted and compiled code to run side-by-side, as well as decompilation to reoptimize and outputting generated bytecode as Java class files.JRuby Programming
Ruby meets Java
JRuby is essentially the Ruby interpreter, except this version is written entirely in Java. JRuby features some of the same concepts, including
object-oriented programming , and duck-typing as Ruby. The key difference is that JRuby is tightly integrated with Java, and can be called directly from Java programs [cite web
url=http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html
publisher=javaworld.com
title=Script your Java applications and efficiently reuse your Java libraries with this dynamic language
Last=Fox|First=Joshua
date=2006-07-17
accessdate=2008-04-26] .Calling Java from JRuby
One powerful feature of JRuby is its ability to invoke the classes of the
Java Platform . To do this, one must first load JRuby's Java support, by calling "include Java" ("require 'java'" in earlier versions). The following example creates a Java Javadoc:SE|javax/swing|JFrame with a Javadoc:SE|javax/swing|JLabel:include Java frame = javax.swing.JFrame.new()frame.getContentPane().add(javax.swing.JLabel.new('Hello, World!'))frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)frame.pack()frame.set_visible(true)JRuby also allows the user to call Java code using the more Ruby-like underscore method naming and to refer to
JavaBean properties as attributes:frame.content_pane.add labelframe.visible = true Calling JRuby from Java
JRuby can just as easily be called from Java, using either the
JSR 223 [ [http://jcp.org/aboutJava/communityprocess/final/jsr223/index.html JSR 223: Scripting for the Java Platform Specification Request] ] Scripting for Java 6 or the Apache Bean Scripting framework. More information on this is available in the [http://www.headius.com/jrubywiki JRuby Wiki] .Performance
JRuby supports interpreted mode, AOT mode, and JIT mode (the last two modes are available since version 1.1).
Interpreted mode
In this mode, JRuby is slower than the C Ruby Reference implementation [cite web
url=http://headius.blogspot.com/2007/04/paving-road-to-jruby-10-performance.html
title=Paving the Road to JRuby 1.0: Performance
date=2007-04-16
last=Nutter|first=Charles
accessdate=2007-11-05] .For example, serving up Rails requests in the standard interpreted mode, JRuby is 50% to 70% slower than C Ruby 1.8.
When using Ruby 1.9 (
YARV ) benchmarks on Java 6, JRuby is 4 times slower than Ruby (including startup time) [when removing a few specific test cases, it is only 50% slower than Ruby 1.8: thread_create_join, sieve, count_words, mandelbrot, and answer, 5 tests out of 39] .Just-in-time compilation mode
JIT mode is available since JRuby 1.1. In performance benchmarks, JRuby is faster in most cases than C Ruby 1.8 [cite web
url=http://headius.blogspot.com/2007/10/performance-update.html
title=Performance Update
date=2007-10-12
last=Nutter|first=Charles
accessdate=2007-10-12] [cite web
url=http://headius.blogspot.com/2007/11/updated-alioth-numbers-for-jruby-11b1.html
title=Performance Update
date=2007-10-12
last=Nutter|first=Charles
accessdate=2007-10-12] but still slower than C Ruby 1.9. However, the JRuby Team claims that the performance of the 1.1 version is approaching, or starting to exceed C Ruby 1.9 in some benchmarks [cite web
url=http://headius.blogspot.com/2008/02/jruby-rc2-released-whats-next.html
title=JRuby RC2 Released; What's Next?
date=2008-02-16
last=Nutter|first=Charles
quote="JRuby's performance regularly exceeds Ruby 1.8.6, and in many cases has started to exceed Ruby 1.9."
accessdate=2008-02-17] .Also in a real Mongrel
web server application, JRuby performance is better than Ruby (after the Virtual Machine has instantiated) [cite web
url=http://blog.nicksieger.com/articles/2007/10/25/jruby-on-rails-fast-enough
title=JRuby on Rails: Fast Enough
date=2007-10-25
last=Sieger|first=Nick
accessdate=2007-10-28] .ee also
*
XRuby
* Grails
* JACL
*Jython
*YARV
* ZK (an Ajax framework supporting JRuby)
* Monkeybars
*Da Vinci Machine References
External links
* [http://www.jruby.org/ The JRuby home page]
* [http://www.headius.com/jrubywiki The JRuby Wiki]
* [http://www.jrubyhub.com/ JRubyHub.com: The hub for all resources related to JRuby and JRuby on Rails (JRoR)]
* [http://www.headius.com/jrubywiki/index.php/Roadmap_%28January_2007_-_June_2007%29 JRuby Roadmap for 2007]
* [http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/ The Great Ruby Shootout: JRuby compared to other Ruby VMs]
* [http://www-128.ibm.com/developerworks/java/library/j-alj09084/ Article on JRuby at IBM DeveloperWorks]
* [http://www.javaworld.com/javaworld/jw-02-2007/jw-02-jruby.html Joshua Fox, "JRuby on Rails"] , JavaWorld
* [http://www.javaworld.com/javaworld/jw-11-2007/jw-11-jsr223.html Scripting on the Java platform] , JavaWorld
* [http://wiki.netbeans.org/wiki/view/NetbeansedJRuby JRuby development in NetBeans]
* [http://www.digitalsanctum.com/2007/07/24/jruby-deploying-a-rails-application-on-tomcat/ Deploying a Rails Application in Tomcat]
* [http://www.digitalsanctum.com/2007/07/25/calling-rubys-activerecord-from-java-using-the-bean-scripting-framework/ Calling Ruby’s ActiveRecord from Java Using the Bean Scripting Framework]
* [http://blogs.sun.com/sabada/entry/deploying_jruby_on_rails_war Deploying JRuby on Rails application on Sun Java System Web Server 7]
* [http://bitnami.org/stack/jrubystack Easy to install distribution of JRuby, Tomcat and Glassfish]
* [http://blogs.sun.com/arungupta/entry/screencast_web6_first_jruby_app Arun's Flash Demo: First JRuby app in GlassFish V2]
* [http://blogs.sun.com/arungupta/entry/first_jruby_on_rails_app First JRuby app in GlassFish V3]Media
*YouTube|PfnP-8XbJao|JRuby: The power of Java and Ruby
* [http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-9294&yr=2007&track=9 JavaOne 2007 Exploiting JRuby]
* [http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-9370&yr=2007&track=9 JavaOne 2007 JRuby on Rails]
* [http://www.netbeans.org/download/flash/jruby_on_rails/jruby_on_rails.html Roumen's Ruby Flash Demo (Part One): JRuby on Rails in NetBeans]
* [http://www.netbeans.org/download/flash/jruby_editing/jruby_editing.html Roumen's Ruby Flash Demo (Part Two): Advanced JRuby editing features in NetBeans]
*Java Posse , [http://www.javaposse.com/index.php?post_id=171709 Interview with Charles Oliver Nutter and Thomas Enebo] about JRuby
Wikimedia Foundation. 2010.