Ruby Programming/Embedding Ruby
Embedding Ruby[edit | edit source]
Full Ruby[edit | edit source]
You can embed Ruby your other C apps, though it is a bit tricky.
is a good reference. The trickiest part is I think you can only run it from your apps "main" thread or else it won't do its stack-traversal for garbage collection right. This may not be the case with jruby or Rubinius et al, and possibly might not be the case for 1.9, too (might work there).
Basically you can call any "rb_" method defined in ruby.h after calling init, and they all return you a VALUE object (ruby object).
NB that you can call from ruby into C by writing a C extension. That is the standard way to go.
mruby[edit | edit source]
mruby a light weight implementation of Ruby 1.9 written by matz, the original Ruby developer. It allows you to run multiple copies of Ruby inside one program, and is easier to integrate with other software than the full Ruby interpreter. It's github page is here: