xruby_overview_20070831

24
XRuby Enjoy Ruby on JVM Ye Zheng http://dreamhead.blogb us.com

Upload: dreamhead

Post on 15-May-2015

582 views

Category:

Technology


0 download

DESCRIPTION

XRuby Overview

TRANSCRIPT

Page 1: XRuby_Overview_20070831

XRubyEnjoy Ruby on JVM

Ye Zheng

http://dreamhead.blogbus.com

Page 2: XRuby_Overview_20070831

Agenda

What is XRuby XRuby Architecture XRuby Jump Start More on XRuby

Page 3: XRuby_Overview_20070831

Agenda

What is XRuby XRuby Architecture XRuby Jump Start More on XRuby

Page 4: XRuby_Overview_20070831

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

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

Two Ways to JVM(I)

Interpretationcurrent C Ruby wayeasy to portneeds interpretation engineslow

RubyScript

Parser AST

Page 7: XRuby_Overview_20070831

Two Ways to JVM(II)

Compilationneeds more explorations uses JVM as execution engineprotects source code fast

RubyScript

Compiler .class

Page 8: XRuby_Overview_20070831

Why Compilation is Faster

Compilation is faster than interpretation

JVM JVM

Interpretation Engine

Ruby Script

Ruby Script

Interpretation Compilation

Page 9: XRuby_Overview_20070831

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

Agenda

What is XRuby XRuby Architecture XRuby Jump Start More on XRuby

Page 11: XRuby_Overview_20070831

XRuby Architecture (overview)

XRuby

Compiler Runtime

Parser

Codegen

Codedom

Lang

Builtin

Java Support

Page 12: XRuby_Overview_20070831

XRuby Architecture (compiler)

Parser.rb .classTree

ParserCodeGen

ASTCodeDom

Antlr ASM

XRuby Compiler

Page 13: XRuby_Overview_20070831

XRuby Architecture (runtime)

Dynamic Language Support

Builtin Java Support

XRuby Runtime

Page 14: XRuby_Overview_20070831

Agenda

What is XRuby XRuby Architecture XRuby Jump Start More on XRuby

Page 15: XRuby_Overview_20070831

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

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

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

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

Agenda

What is XRuby XRuby Architecture XRuby Start-up More on XRuby

Page 20: XRuby_Overview_20070831

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

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

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

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

Welcome to XRuby