Slide 1

Slide 1 text

नमस्कार!

Slide 2

Slide 2 text

Sameer Deshmukh @v0dro @v0dro

Slide 3

Slide 3 text

Pune | पुणे

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Ruby Science Foundation www.sciruby.com @sciruby @sciruby

Slide 7

Slide 7 text

Ruby speed reliability C

Slide 8

Slide 8 text

Ruby speed reliability C Nokogiri Nokogiri::XML() fast_blank String#blank? libxml Handwritten C

Slide 9

Slide 9 text

Rubex: Highly productive C extensions.

Slide 10

Slide 10 text

Rubex code C code CRuby runtime Language which looks like Ruby. Code ready to interface with Ruby. Code actually runs here.

Slide 11

Slide 11 text

def fibo(n) a, b, i, temp = 1, 1, 0, nil print a, "\n" print b, "\n" while i < n do temp = b b = a + b a = temp i += 1 print b, "\n" end end fibo(10);

Slide 12

Slide 12 text

VALUE cfibo(VALUE obj_n, VALUE self) { int n = INT2FIX(obj_n); int i = 0, a = 1, b = 1, temp = 0; printf("%d\n", a); printf("%d\n", b); while (i < n) { temp = b; b = a + b; a = temp; i += 1; print("%d\n", b); } return self; } Init_fibo(void) { rb_define_global_function("fibo", cfibo, 1); }

Slide 13

Slide 13 text

BIG Problems ● Difficult and irritating to write. ● Debugging is time consuming. ● Remember the CRuby C API. ● Need to care about small things.™* *Matz.

Slide 14

Slide 14 text

def fibo(int n) int a = 1, b = 1, i = 0, temp = 0 print a, "\n" print b, "\n" while i < n do temp = b b = a + b a = temp i += 1 print b, "\n" end end

Slide 15

Slide 15 text

def fibo(int n) int a = 1, b = 1, i = 0, temp = 0 print a, "\n" print b, "\n" while i < n do temp = b b = a + b a = temp i += 1 print b, "\n" end end

Slide 16

Slide 16 text

Salient Features ● Looks exactly like Ruby but with the ability to declare C types. ● Implicit, transparent conversion and interfacing between Ruby and C. ● Compiles to C code so is super fast. ● Simple and intuitive interfaces to the Ruby GC. ● Interface with external C libraries.

Slide 17

Slide 17 text

https://github.com/v0dro/rubex

Slide 18

Slide 18 text

Functional libcsv wrapper Ruby gem in examples/ folder written entirely in Rubex.

Slide 19

Slide 19 text

I haz SciRuby stickers. ^_^

Slide 20

Slide 20 text

THANK YOU!