DEV Community


Discussion on: Creating Ruby native extensions

vinistock profile image
Vinicius Stock Author

I haven't used Helix before, but it does seem interesting. I know there are other alternatives for writing native exntesions in Crystal and in Java. I wonder if they differ significantly in performance.

mikhailkrainik profile image
Mikhail Krainik

As told there

Performance parity with C
In general, Rust is in the same performance ballpark as C for code >written in Rust (sometimes it’s even faster). However, the cost of >crossing from Ruby to Rust is still high (compared to Ruby C >extensions).

That being said, because using native code is so much faster than >Ruby, you can recoup the cost difference pretty quickly. This >problem is more important for chatty APIs, or drop-in replacements >for Ruby APIs that intrinsically require a lot of communication with >Ruby (e.g. to_str).