| Developed by | Charles Nutter, Thomas Enebo, Ola Bini and Nick Sieger |
|---|---|
| Latest release | 1.1.5 / 03 November 2008 |
| Preview release | 1.1.6 RC1 / 03 December 2008 |
| Written in | Ruby and Java |
| OS | Cross-platform |
| Platform | Java Virtual Machine |
| Type | 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 [1], Thomas Enebo [2] Ola Bini [3] and Nick Sieger [4]. In September 2006, Sun Microsystems hired Enebo and Nutter to work on JRuby full time.[1] In June 2007, ThoughtWorks hired Ola Bini to work on Ruby and JRuby.[2]
Contents |
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 [5] [6].
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 implementation[3][4].
JRuby 1.1.1 is stated to be packaged in Fedora 9[5][6].
Since version 1.1.1, the JRuby team began to issue point releases often to quickly address issues that are brought up by users[7].
Rails
JRuby has supported Ruby on Rails since version 0.9 (May 2006) [8][9], with the ability to execute RubyGems and WEBrick. Since the hiring of the two lead developers by Sun, Rails compatibility and speed have improved greatly. JRuby version 1.0 successfully passed nearly all of Rails' own test cases[10]. Since then, developers have begun to use JRuby for Rails applications in production environments [11].
Multiple Virtual Machine Collaboration
On February 27, 2008, Sun Microsystems and the University 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[12].
Dynamic Invocation on Java Virtual Machines
JSR 292 (Supporting Dynamically Typed Languages on the JavaTM Platform) [13] propose to:
- add a new
invokedynamicinstruction 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[14]. The first working prototype, developed as a patch on OpenJDK, was announced and made available on end of August 2008[15][16].
The JRuby team has successfully wired dynamic invocation in their codebase, albeit in a very primitive way. Dynamic invocation shipped with the 1.1.5 release, although being disabled on JVMs without Dynamic invocation capabilities[17].
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.1[18]. 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[19].
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 JFrame with a 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 label frame.visible = true
Calling JRuby from Java
JRuby can just as easily be called from Java, using either the JSR 223[20] Scripting for Java 6 or the Apache Bean Scripting framework. More information on this is available in the JRuby Wiki article.
Performance
JRuby supports interpreted mode, AOT mode, and JIT mode (the last two modes are available since version 1.1[18]).
Interpreted mode
In this mode, JRuby is slower than the C Ruby Reference implementation[21].
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)[22].
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 [23][3] [24] but still slower than C Ruby 1.9[4]. 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 [25].
Also in a real Mongrel web server application, JRuby performance is better than Ruby (after the Virtual Machine has instantiated)[26].
See also
References
- ^ Jacki (2006-09-07). "Sun Welcomes JRuby Developers". On the Record. Retrieved on 2006-09-09.
- ^ Ola Bini. "ThoughtWorks". On the Record.
- ^ a b "JRuby performance benchmark". shootout.alioth.debian.org (2008-09-14). Retrieved on 2008-09-14.
- ^ a b Cangiano, Antonio (2007-03-12). "The Great Ruby Shootout". Retrieved on 2008-02-01.
- ^ Nutter, Charles (2008-04-25). "JRuby 1.1.1 in RedHat Fedora". Retrieved on 2008-04-26.
- ^ "jruby". fedoraproject.org. Retrieved on 2008-04-26.
- ^ "JRuby 1.1.3 Released". jruby.codehaus.org (2008-07-19). Retrieved on 2008-07-19. "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."
- ^ "Rails Support". JRuby Team. Retrieved on 2008-02-17.
- ^ Nutter, Charles (2008-08-24). "Zero to Production in 15 Minutes". Retrieved on 2008-08-27.
- ^ 98.6% of the 2,807 Rails-specific test cases execute successfully; see JRuby 0.9.8 Released
- ^ "Success Stories". JRuby Wiki (2008-01-29). Retrieved on 2008-02-17.
- ^ "The University of Tokyo and Sun Microsystems Commence Joint Research Projects on High Performance Computing and Web-based Programming Languages". Sun Microsystems (2008-02-27). Retrieved on 2008-02-28.
- ^ see JSR 292
- ^ "Sub-Projects and Investigations". Sun Microsystems (2007). Retrieved on 2008-02-06.
- ^ Rose, John (2008-08-26). "Happy International Invokedynamic Day!". Retrieved on 2008-09-03.
- ^ Lorimer, R.J. (2008-09-01). "Dynamic Invocation Runs on OpenJDK". infoq.com. Retrieved on 2008-09-03.
- ^ Nutter, Charles (2008-09-11). "A First Taste of InvokeDynamic". Retrieved on 2008-09-13. "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)."
- ^ a b Nutter, Charles (2007-09-27). "The Compiler Is Complete". Retrieved on 2007-10-12.
- ^ "Script your Java applications and efficiently reuse your Java libraries with this dynamic language". javaworld.com (2006-07-17). Retrieved on 2008-04-26.
- ^ JSR 223: Scripting for the Java Platform Specification Request
- ^ Nutter, Charles (2007-04-16). "Paving the Road to JRuby 1.0: Performance". Retrieved on 2007-11-05.
- ^ 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
- ^ Nutter, Charles (2007-10-12). "Performance Update". Retrieved on 2007-10-12.
- ^ Nutter, Charles (2007-10-12). "Performance Update". Retrieved on 2007-10-12.
- ^ Nutter, Charles (2008-02-16). "JRuby RC2 Released; What's Next?". Retrieved on 2008-02-17. "JRuby's performance regularly exceeds Ruby 1.8.6, and in many cases has started to exceed Ruby 1.9."
- ^ Sieger, Nick (2007-10-25). "JRuby on Rails: Fast Enough". Retrieved on 2007-10-28.
External links
- The JRuby home page
- The JRuby Wiki
- JRubyHub.com: The hub for all resources related to JRuby and JRuby on Rails (JRoR)
- JRuby Roadmap for 2007
- The Great Ruby Shootout: JRuby compared to other Ruby VMs
- Article on JRuby at IBM DeveloperWorks
- Joshua Fox, "JRuby on Rails", JavaWorld
- Scripting on the Java platform, JavaWorld
- JRuby development in NetBeans
- Deploying a Rails Application in Tomcat
- Calling Ruby’s ActiveRecord from Java Using the Bean Scripting Framework
- Deploying JRuby on Rails application on Sun Java System Web Server 7
- Easy to install distribution of JRuby, Tomcat and Glassfish
- Arun's Flash Demo: First JRuby app in GlassFish V2
- First JRuby app in GlassFish V3
Media
- JRuby: The power of Java and Ruby at YouTube
- JavaOne 2007 Exploiting JRuby
- JavaOne 2007 JRuby on Rails
- Roumen's Ruby Flash Demo (Part One): JRuby on Rails in NetBeans
- Roumen's Ruby Flash Demo (Part Two): Advanced JRuby editing features in NetBeans
- Java Posse, Interview with Charles Oliver Nutter and Thomas Enebo about JRuby
|
||||||||||||||
No comments have been added.





