Save 37% off PRO during our Black Friday Sale! »

Deccan Ruby Conf 2017 Rubex intro

Deccan Ruby Conf 2017 Rubex intro

A lightning talk briefly describing Rubex with a simple example.

5083e35c5075b75473919524286239b3?s=128

Sameer Deshmukh

August 12, 2017
Tweet

Transcript

  1. नमस्कार!

  2. Sameer Deshmukh @v0dro @v0dro

  3. Pune | पुणे

  4. None
  5. None
  6. Ruby Science Foundation www.sciruby.com @sciruby @sciruby

  7. Ruby speed reliability C

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

    C
  9. Rubex: Highly productive C extensions.

  10. Rubex code C code CRuby runtime Language which looks like

    Ruby. Code ready to interface with Ruby. Code actually runs here.
  11. 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);
  12. 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); }
  13. BIG Problems • Difficult and irritating to write. • Debugging

    is time consuming. • Remember the CRuby C API. • Need to care about small things.™* *Matz.
  14. 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
  15. 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
  16. 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.
  17. https://github.com/v0dro/rubex

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

    in Rubex.
  19. I haz SciRuby stickers. ^_^

  20. THANK YOU!