Slide 1

Slide 1 text

ruby without the syntax

Slide 2

Slide 2 text

Faraaz Ahmad Twitter: @Faraaz98 Github: faraazahmad

Slide 3

Slide 3 text

interpreted? / compiled?

Slide 4

Slide 4 text

Y E S

Slide 5

Slide 5 text

Compiled, then interpreted 1 + 2 putobject 1 putobject 2 opt_plus leave

Slide 6

Slide 6 text

Yet Another Virtual Machine a.k.a YARV putobject 1 putobject 2 opt_plus leave YARV 010101010101 100001010101 001010101010 101000010101 010100001011

Slide 7

Slide 7 text

W.W.Y.D. What Would YARV Do?

Slide 8

Slide 8 text

github.com/ruby/ruby

Slide 9

Slide 9 text

Ruby on Cocaine…

Slide 10

Slide 10 text

Ruby C API

Slide 11

Slide 11 text

Ruby: def foo; end YARV: definemethod foo C API: rb_define_global_function( "foo", my_method, argc );

Slide 12

Slide 12 text

class.c

Slide 13

Slide 13 text

Top level methods are stored in the Kernel module > puts 25 25 => nil > Kernel.puts 25 25 => nil

Slide 14

Slide 14 text

Top level methods are stored in the Kernel module > def foo = 420 => :foo > Kernel.private_methods => [..., :foo, ...]

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

PseudoRuby Examples

Slide 17

Slide 17 text

Init the VM

Slide 18

Slide 18 text

Sum of 2 numbers

Slide 19

Slide 19 text

Sum of 2 numbers

Slide 20

Slide 20 text

Area of circle

Slide 21

Slide 21 text

Area of circle

Slide 22

Slide 22 text

Define module and class

Slide 23

Slide 23 text

You can do all of it (I think) rb_require(...); rb_load(...); rb_raise( rb_eRuntimeError, "Error code %d", 404 ); VALUE gv; rb_gv_set("$x", gv); gv = rb_gv_get("$x"); iv = rb_iv_get(obj, "@x");

Slide 24

Slide 24 text

Comparison

Slide 25

Slide 25 text

Ship your Ruby program as a single binary

Slide 26

Slide 26 text

Resources http://silverhammermba.github.io/emberb/c/ http://github.com/faraazahmad/pseudoruby

Slide 27

Slide 27 text

But why?

Slide 28

Slide 28 text

But why not?

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Mess-around driven development

Slide 33

Slide 33 text

Mess-around driven development

Slide 34

Slide 34 text

Mess-around be nice. have fun.

Slide 35

Slide 35 text

Thank you