How is magic formed

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

How is magic formed

Short excursion into Ruby Internals, Ruby Usergroup Berlin, June 3rd 2014

Rin Raeuber

July 03, 2014

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

31 slides
  1. 9 . times do puts "" Tokens 9 . t

    i m e s … integer identifier identifier period keyword strin
  2. YARV instructions “Yet Another Ruby Virtual Machine” == catch table

    | catch type: break st: 0002 ed: 0006 sp: 0000 cont: 0006 |-------------------------------------------------------------- 0000 trace 1 0002 putobject 9 0004 send <callinfo!mid:times, argc:0, block:block 0006 leave == disasm: <RubyVM::InstructionSequence:block in <compiled>@<co == catch table | catch type: redo st: 0000 ed: 0009 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0009 sp: 0000 cont: 0009 |-------------------------------------------------------------- 0000 trace 256 0002 trace 1 0004 putself 0005 putstring "Ente"
  3. struct meetup { char title[120]; time_t starts_at; bool has_talks; union

    { char address[120]; struct position { int latitude; int longitude; } } };
  4. RObject struct RObject { struct RBasic basic; struct { long

    numiv; VALUE *ivptr; struct st_table *iv_index_tbl; } heap; }; simplified
  5. RObject struct RObject { struct RBasic basic; union { struct

    { long numiv; VALUE *ivptr; struct st_table *iv_index_tbl; } heap; VALUE ary[ROBJECT_EMBED_LEN_MAX]; } as; };
  6. - Reading C is not that bad.* 
 *(If you

    hate it, you can still look at the Standard Library or Rubinius.)! ! - Check out the Ruby source code
 and give a talk about it. ;) Things to take home
  7. Never create Ruby Strings longer than 23 characters ! Ruby

    under a microscope (the book) ! The Ruby Hacking Guide (Warning: Ruby 1.7.3!) ! A Tour of the Ruby MRI Source Code with Pat Shaughnessy Some Links

More Decks by Rin Raeuber

Other Decks in Programming