Rails彻底加快及简化了Web应用的开发,不过它让人觉得不够成熟,特别是在高端企业级功能方面。另一方面,Java平台及其虚拟机、库和 应用服务器的速度、稳定性和功能方面却一直在提升,现在已被公认为是开发高端服务器应用的领先平台。不过如果Java平台不与Ruby等新兴语言联系在一 起,就有可能落后于流行趋势。
示例代码:
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