XRuby_Overview_20070831

806 views

Published on

XRuby Overview

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
806
On SlideShare
0
From Embeds
0
Number of Embeds
35
Actions
Shares
0
Downloads
42
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

XRuby_Overview_20070831

  1. 1. XRuby Enjoy Ruby on JVM Ye Zheng http://dreamhead.blogbus.com
  2. 2. Agenda <ul><li>What is XRuby </li></ul><ul><li>XRuby Architecture </li></ul><ul><li>XRuby Jump Start </li></ul><ul><li>More on XRuby </li></ul>
  3. 3. Agenda <ul><li>What is XRuby </li></ul><ul><li>XRuby Architecture </li></ul><ul><li>XRuby Jump Start </li></ul><ul><li>More on XRuby </li></ul>
  4. 4. What is XRuby <ul><li>XRuby is the first Ruby to Java compiler which compiles Ruby source code (.rb) to Java bytecode (.class). </li></ul>XRuby .rb .class
  5. 5. XRuby current status <ul><li>The latest version is 0.3.0. </li></ul><ul><li>test::unit works. </li></ul><ul><li>XRuby debugger provided </li></ul><ul><li>Java to Ruby binding annotation. </li></ul><ul><li>Runs most benchmark faster than ruby 1.8.6. </li></ul>
  6. 6. Two Ways to JVM(I) <ul><li>Interpretation </li></ul><ul><ul><li>current C Ruby way </li></ul></ul><ul><ul><li>easy to port </li></ul></ul><ul><ul><li>needs interpretation engine </li></ul></ul><ul><ul><li>slow </li></ul></ul>Ruby Script Parser AST
  7. 7. Two Ways to JVM(II) <ul><li>Compilation </li></ul><ul><ul><li>needs more explorations </li></ul></ul><ul><ul><li>uses JVM as execution engine </li></ul></ul><ul><ul><li>protects source code </li></ul></ul><ul><ul><li>fast </li></ul></ul>Ruby Script Compiler .class
  8. 8. Why Compilation is Faster <ul><li>Compilation is faster than interpretation </li></ul>JVM JVM Interpretation Engine Ruby Script Ruby Script Interpretation Compilation
  9. 9. Misunderstandings <ul><li>It erases dynamic language features. </li></ul><ul><ul><li>Dynamic structure written in Java is developed to support dynamic language features </li></ul></ul><ul><li>It maps Ruby class to Java class directly. </li></ul><ul><ul><li>Ruby class is a dynamic language structure, and it is different from Java class which is a static structure </li></ul></ul>
  10. 10. Agenda <ul><li>What is XRuby </li></ul><ul><li>XRuby Architecture </li></ul><ul><li>XRuby Jump Start </li></ul><ul><li>More on XRuby </li></ul>
  11. 11. XRuby Architecture (overview) XRuby Compiler Runtime Parser Codegen Codedom Lang Builtin Java Support
  12. 12. XRuby Architecture (compiler) Parser .rb .class Tree Parser Code Gen AST Code Dom Antlr ASM XRuby Compiler
  13. 13. XRuby Architecture (runtime) Dynamic Language Support Builtin Java Support XRuby Runtime
  14. 14. Agenda <ul><li>What is XRuby </li></ul><ul><li>XRuby Architecture </li></ul><ul><li>XRuby Jump Start </li></ul><ul><li>More on XRuby </li></ul>
  15. 15. XRuby Jump Start (Ruby code) <ul><li>class MyClass </li></ul><ul><li>def say_hello_three_times </li></ul><ul><li>3.times { puts &quot;hello&quot;} </li></ul><ul><li>end </li></ul><ul><li>end </li></ul><ul><li>MyClass.new.say_hello_three_times </li></ul>
  16. 16. XRuby Jump Start (compile and run) <ul><li>Compile </li></ul><ul><ul><li>java -jar xruby-0.3.0.jar -c demo.rb </li></ul></ul><ul><li>Run </li></ul><ul><ul><li>java -jar demo.jar </li></ul></ul><ul><li>Output </li></ul><ul><ul><li>hello </li></ul></ul><ul><ul><li>hello </li></ul></ul><ul><ul><li>hello </li></ul></ul>
  17. 17. XRuby Jump Start (builtin) <ul><li>@RubyLevelClass(name=&quot;Array&quot;) </li></ul><ul><li>public class RubyArray … { </li></ul><ul><li>… </li></ul><ul><li>@RubyLevelMethod(name=&quot;length&quot;) </li></ul><ul><li>public RubyFixnum length() { </li></ul><ul><li>return ObjectFactory.createFixnum(this.array_.size()); </li></ul><ul><li>} </li></ul><ul><li>… </li></ul><ul><li>} </li></ul>
  18. 18. XRuby Jump Start (reference) <ul><li>XRuby Hacking Guide is a good start to understand XRuby. </li></ul><ul><li>Ruby Hacking Guide is a good reference to Ruby implementation. </li></ul><ul><li>Builtin is a good start and reference to XRuby code. </li></ul>
  19. 19. Agenda <ul><li>What is XRuby </li></ul><ul><li>XRuby Architecture </li></ul><ul><li>XRuby Start-up </li></ul><ul><li>More on XRuby </li></ul>
  20. 20. XRuby’s Future <ul><li>XRuby 0.4.0 </li></ul><ul><ul><li>Pass all C Ruby tests (Milestone) </li></ul></ul><ul><ul><li>Compile multiple ruby scripts into one jar </li></ul></ul><ul><ul><li>Implement more builtin libraries </li></ul></ul><ul><ul><li>Improve performance </li></ul></ul><ul><li>Long Term </li></ul><ul><ul><li>Make Ruby on Rails work </li></ul></ul><ul><ul><li>Upgrade Antlr to 3.0 </li></ul></ul>
  21. 21. Contribution to XRuby <ul><li>Principles </li></ul><ul><ul><li>Every contribution is welcome. </li></ul></ul><ul><ul><li>Every attempt is encouraged. </li></ul></ul><ul><li>Approaches </li></ul><ul><ul><li>Use XRuby </li></ul></ul><ul><ul><li>Report bugs </li></ul></ul><ul><ul><li>Commit patches. </li></ul></ul><ul><ul><li>Join mailing list to share ideas. </li></ul></ul><ul><ul><li>Become a XRuby project member. </li></ul></ul><ul><ul><li>… </li></ul></ul>
  22. 22. Enjoy XRuby <ul><li>Enjoy development of a compiler. </li></ul><ul><li>Ruby is a elegant language. </li></ul><ul><li>Work with JVM. </li></ul><ul><li>Understand dynamic language internals. </li></ul><ul><li>Contribute to open source. </li></ul><ul><li>We can grow with XRuby since it’s new. </li></ul>
  23. 23. For More Information <ul><li>Homepage </li></ul><ul><ul><li>http://www.xruby.com </li></ul></ul><ul><li>Project Homepage </li></ul><ul><ul><li>http://code.google.com/p/xruby/ </li></ul></ul><ul><li>Project Blog </li></ul><ul><ul><li>http://xruby.blogspot.com </li></ul></ul><ul><li>Project Group </li></ul><ul><ul><li>http://groups.google.com/group/xruby-devel </li></ul></ul>
  24. 24. Welcome to XRuby

×