Ruby-mri-rs - embedding a Ruby VM in Rust programs


#1

I’ve started playing with writing bindings to the Ruby MRI for Rust programs. I’ve basically just been transcribing things from ruby.h so far, with the barest work on higher-level bindings. I welcome contributions from anybody else who’s interested in making this possible! It’s a fun way to learn more about Ruby and how to create Rustic APIs!

https://crates.io/crates/ruby-mri


#2

It’d be fun to discuss the Value APIs. I’ll probably have to deal with similar challenges in the Gtk-rs project since gobject has a Value type too.

While there’s not much meat there yet, I’d just advise against this:

use self::ffi::*;

In my experience it’s neater when the ffi:: qualifiers are explicit, making the use of ruby.h constants and the calls across the FFI boundary more apparent.


#3

Interesting. Why did you opt for MRI instead of MRuby?


#4

Because I know nothing about Ruby interpreters besides JRuby.


#5

I’m excited about this project!

MRuby is a new Ruby specifically targeted at the Lua case: embedding in other languages. So yeah, it would be cool to try as well.


#6

No issue there, just that - as @steveklabnik says - MRI is not exactly built for embedding to the point where Matz himself created an embeddable version of Ruby.

Looking forward to see what comes out of your project :).