Found this post and video about Helix, which makes building native Rust code that is callable from Ruby much, much easier. This has interested me enough to make me want to look a little more deeply at Rust!
Awesome! I’ve been into Rust for several months now for this very same reason. My most recent blog post on it: https://blog.codeship.com/coming-rust-ruby/
Steve Klabnik has made an awesome presentation at a Ruby conference on Rust & Ruby (video in awesome conference talks). Steve Klabnik shows 3 original ways to do it in his talk. This would be pre RuRu, ruby-sys, and helix which are all Rust libraries for integrating Ruby & Rust. Steve Klabnik is also one of the biggest contributors to these projects and was in charge of writing/updating most of the Rust languages documentation.
Yeah. I’m pretty familiar with Steve’s work. I’ll definitely check those out. Would love to get some type safety and speed into certain parts of my Ruby code, without giving up the Ruby syntax and developer friendliness.
Steve’s Rust + Ruby talk was good. I didn’t know about Fiddle. I haven’t done much embedding in Ruby though, so that may account for it.
That’s the only way I’ve done it so far. Back in January I implemented some combinatorial methods in both Rust and Ruby and benchmarked them. combination_count.rb
I’ve written a Ruby gem that will actually compile your Rust code when you
bundle it. My new gem is called FasterPath and it’s for rewriting Ruby’s path related methods in Rust since this is one of the costliest areas in Ruby web hosting. I’m so happy it’s working so well.
I didn’t use any C code, Helix, or Fiddle. I only used FFI for dynamically linking and hacked the
extconf.rb makefile creator to run some Rust rake tasks I created when the gem installs. The
extconf.rb file is designed for building native extensions in Ruby gems.
The reason I didn’t use Helix is the learning curve would be more time then I was willing to put in as there isn’t enough getting started documentation on it. There is no crate or ruby gem for it, just the repo.