xruby_overview_20070831
DESCRIPTION
XRuby OverviewTRANSCRIPT
XRubyEnjoy Ruby on JVM
Ye Zheng
http://dreamhead.blogbus.com
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
What is XRuby
XRuby is the first Ruby to Java compiler which compiles Ruby source code (.rb) to Java bytecode (.class).
XRuby.rb .class
XRuby current status
The latest version is 0.3.0. test::unit works. XRuby debugger provided Java to Ruby binding annotation. Runs most benchmark faster than ruby 1.8.
6.
Two Ways to JVM(I)
Interpretationcurrent C Ruby wayeasy to portneeds interpretation engineslow
RubyScript
Parser AST
Two Ways to JVM(II)
Compilationneeds more explorations uses JVM as execution engineprotects source code fast
RubyScript
Compiler .class
Why Compilation is Faster
Compilation is faster than interpretation
JVM JVM
Interpretation Engine
Ruby Script
Ruby Script
Interpretation Compilation
Misunderstandings
It erases dynamic language features.Dynamic structure written in Java is
developed to support dynamic language features
It maps Ruby class to Java class directly.Ruby class is a dynamic language structure,
and it is different from Java class which is a static structure
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
XRuby Architecture (overview)
XRuby
Compiler Runtime
Parser
Codegen
Codedom
Lang
Builtin
Java Support
XRuby Architecture (compiler)
Parser.rb .classTree
ParserCodeGen
ASTCodeDom
Antlr ASM
XRuby Compiler
XRuby Architecture (runtime)
Dynamic Language Support
Builtin Java Support
XRuby Runtime
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
XRuby Jump Start (Ruby code)
class MyClass
def say_hello_three_times
3.times { puts "hello"}
end
end
MyClass.new.say_hello_three_times
XRuby Jump Start (compile and run)
Compile java -jar xruby-0.3.0.jar -c demo.rb
Run java -jar demo.jar
Outputhello
hello
hello
XRuby Jump Start (builtin)
@RubyLevelClass(name="Array")public class RubyArray … { … @RubyLevelMethod(name="length") public RubyFixnum length() { return ObjectFactory.createFixnum(this.array_.size()); } …}
XRuby Jump Start (reference)
XRuby Hacking Guide is a good start to understand XRuby.
Ruby Hacking Guide is a good reference to Ruby implementation.
Builtin is a good start and reference to XRuby code.
Agenda
What is XRuby XRuby Architecture XRuby Start-up More on XRuby
XRuby’s Future
XRuby 0.4.0Pass all C Ruby tests (Milestone) Compile multiple ruby scripts into one jar Implement more builtin libraries Improve performance
Long TermMake Ruby on Rails work Upgrade Antlr to 3.0
Contribution to XRuby Principles
Every contribution is welcome.Every attempt is encouraged.
ApproachesUse XRubyReport bugsCommit patches.Join mailing list to share ideas.Become a XRuby project member.…
Enjoy XRuby
Enjoy development of a compiler. Ruby is a elegant language. Work with JVM. Understand dynamic language internals. Contribute to open source. We can grow with XRuby since it’s new.
For More Information
Homepage http://www.xruby.com
Project Homepage http://code.google.com/p/xruby/
Project Blog http://xruby.blogspot.com
Project Group http://groups.google.com/group/xruby-devel
Welcome to XRuby