Rubinius: Ruby ½°¸°½½‹¹ ½° Ruby

  • View
    1.838

  • Download
    6

Embed Size (px)

DESCRIPTION

Rubinius: Ruby written on Ruby.Devcon '10. Moscow, Russia, 17, May

Text of Rubinius: Ruby ½°¸°½½‹¹ ½° Ruby

  • 1. Rubinius: Ruby, Ruby

2. 2006 , - Ruby ? 3. Rubinius? Ruby LLVM JIT Engine Yard Evan Phoenix VM Melbourne Bytecode 4. , Ruby, : puts123 : push %rbp; mov %rsp, %rbp;push %rbx; subq $0x98, %rsp;cmp $0x0, 0x10(%rcx);call 0xffffffffff472010;jmp 0x9c; Rubinius : 5. Ruby Rubinius : 6. , Rubinius Ruby?

  • ! , :
  • Java ;
  • Ruby, C++;

7. , Rubinius Ruby? staticVALUErb_ary_collect (ary) VALUE ary; { longi; VALUE collect; if(!rb_block_given_p()) { returnrb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr); } collect = rb_ary_new2(RARRAY(ary)->len); for(i = 0; i < RARRAY(ary)->len; i++) { rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i])); } returncollect; } 8. , Rubinius Ruby? moduleEnumerable def collect if block_given? ary=[] each { |o| ary String failed (TypeError) Backtrace: Type.coerce_to at kernel/common/type.rb:22 Kernel(String)#StringValue at kernel/common/kernel.rb:112 String#+ at kernel/common/string.rb:78 main.__script__ at z.rb:1 Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:65 Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:88 Rubinius::Loader#script at kernel/loader.rb:435 Rubinius::Loader#main at kernel/loader.rb:526 Rubinius::Loader.main at kernel/loader.rb:552 Object#__script__ at kernel/loader.rb:564 ruby z.rb z.rb:1:in `+': can't convert Fixnum into String (TypeError) from z.rb:1 25. # -*- array_zen -*- q= + [ x ** 2 , x.in([1,2,3])] p q# => [1, 4, 9] 26.

  • Mspec
  • RubySpec

describe"Array#shift" do it"removes and returns the first element" do a=[5, 1, 1, 5, 4] a.shift.should==5 end it"returns nil when the array is empty" do [].shift.should== nil end end 27. Rubinius:

  • Windows;
  • ;
  • ;
  • (C, Ruby);
  • ;

28. :

  • x=0
  • loop do
  • puts x > -123 # => true
  • end

29. :

  • JIT
  • Debugger
  • 1.9
  • Windows

30. rubinius 1.0.0 (1.8.7 e6c32afd 2010-05-14 JI) ruby 1.9.2dev (2010-04-14 trunk 27342) ruby 1.8.7 (2010-01-10 patchlevel 249) jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2010-04-14 7cb1298) MacRuby version 0.6 (ruby 1.9.0) 31. def fib (n) if(n