xruby_overview_20070831
DESCRIPTION
XRuby OverviewTRANSCRIPT
![Page 1: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/1.jpg)
XRubyEnjoy Ruby on JVM
Ye Zheng
http://dreamhead.blogbus.com
![Page 2: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/2.jpg)
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
![Page 3: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/3.jpg)
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
![Page 4: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/4.jpg)
What is XRuby
XRuby is the first Ruby to Java compiler which compiles Ruby source code (.rb) to Java bytecode (.class).
XRuby.rb .class
![Page 5: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/5.jpg)
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.
![Page 6: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/6.jpg)
Two Ways to JVM(I)
Interpretationcurrent C Ruby wayeasy to portneeds interpretation engineslow
RubyScript
Parser AST
![Page 7: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/7.jpg)
Two Ways to JVM(II)
Compilationneeds more explorations uses JVM as execution engineprotects source code fast
RubyScript
Compiler .class
![Page 8: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/8.jpg)
Why Compilation is Faster
Compilation is faster than interpretation
JVM JVM
Interpretation Engine
Ruby Script
Ruby Script
Interpretation Compilation
![Page 9: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/9.jpg)
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
![Page 10: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/10.jpg)
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
![Page 11: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/11.jpg)
XRuby Architecture (overview)
XRuby
Compiler Runtime
Parser
Codegen
Codedom
Lang
Builtin
Java Support
![Page 12: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/12.jpg)
XRuby Architecture (compiler)
Parser.rb .classTree
ParserCodeGen
ASTCodeDom
Antlr ASM
XRuby Compiler
![Page 13: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/13.jpg)
XRuby Architecture (runtime)
Dynamic Language Support
Builtin Java Support
XRuby Runtime
![Page 14: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/14.jpg)
Agenda
What is XRuby XRuby Architecture XRuby Jump Start More on XRuby
![Page 15: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/15.jpg)
XRuby Jump Start (Ruby code)
class MyClass
def say_hello_three_times
3.times { puts "hello"}
end
end
MyClass.new.say_hello_three_times
![Page 16: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/16.jpg)
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
![Page 17: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/17.jpg)
XRuby Jump Start (builtin)
@RubyLevelClass(name="Array")public class RubyArray … { … @RubyLevelMethod(name="length") public RubyFixnum length() { return ObjectFactory.createFixnum(this.array_.size()); } …}
![Page 18: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/18.jpg)
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.
![Page 19: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/19.jpg)
Agenda
What is XRuby XRuby Architecture XRuby Start-up More on XRuby
![Page 20: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/20.jpg)
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
![Page 21: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/21.jpg)
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.…
![Page 22: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/22.jpg)
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.
![Page 23: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/23.jpg)
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
![Page 24: XRuby_Overview_20070831](https://reader036.vdocuments.us/reader036/viewer/2022070315/5555aa62d8b42afe5d8b4712/html5/thumbnails/24.jpg)
Welcome to XRuby