The JRuby community released JRuby 1.7's first preview version today.
JRuby is a pure Java implementation of the Ruby programming language. It integrates Ruby's concise syntax and rich Java class libraries. Through JRuby, you can directly run the Ruby program on the JVM and call the Java class library.
Main improvements to JRuby 1.7 include:
- Ruby 1.9.3 is now the default runtime Mode
- Fixed a lot of issues about Ruby 1.9.x compatibility.
- Supports new bytecode introduced by invokedynamicJava 7 in Java 7. With invokedynamic, you can remove parameters, insert new parameters, process existing parameters and return values, and capture exceptions)
- Improve performance and concurrency
- Gradually remove support for Java 5
- Upgrade RubyGems to 1.8.24
- Rake upgrade to 0.9.2.2
- Fixed 259 bugs
JRuby is an interpreter for Ruby and based on Java Virtual Machine (JVM). It combines the simplicity of the Ruby language with the powerful JVM execution mechanism, including full integration with the Java library. Rails accelerates and simplifies the development of Web applications, but it makes people feel immature, especially in terms of high-end enterprise-level functions. On the other hand, the speed, stability, and functions of the Java platform and its virtual machines, libraries, and application servers have been improved. It is now recognized as a leading platform for developing high-end server applications. However, if the Java platform is not associated with emerging languages such as Ruby, it may fall behind the popular trend.
Sample Code:
- require "java"
-
- include_class "java.util.TreeSet"
- include_class "com.example.CallMe"
- include_class "com.example.ISpeaker"
-
- puts "Hello from ruby"
- set = TreeSet.new
- set.add "foo"
-
- set.add "Bar"
- set.add "baz"
- set.each { |v| puts "value: #{v}" }
-
- cm = CallMe.new
- cm.hello
- $globalCM.hello
-
- class CallJava
- include ISpeaker
- def initialize
- super
- @count = 0
- end
-
- def say(msg)
- puts "Ruby saying #{msg}"
- end
-
- def addOne(from)
- # m.synchronize {
- @count += 1
- puts "Now got #@count from #{from}"
-
- # }
- end
- end
Http://www.jruby.org/2012/05/21/jruby-1-7-0-preview1.html details
Home: http://www.jruby.org/
Download: http://www.jruby.org/download