Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Embedding Rust in Ruby (with demo) (brson.github.com)
30 points by pcwalton on March 13, 2013 | hide | past | favorite | 7 comments


I'm sure there are many Ruby programmers that are competent at low level code, but based on my anecdotal observations, I find the thought of the average Ruby developer writing Rust terrifying...


I think it's a lot less terrifying than writing Ruby extensions in C (which has been the main alternative up to now), because Rust is memory-safe. There's a lot less that can go wrong when you can't scribble on freed memory or jump to undefined addresses outside of designated "unsafe { ... }" blocks. Note that the Gaussian blur function is all safe code—the only unsafe code here is the code to marshal the data structures to and from Ruby.


"less terrifying than writing Ruby extensions in C" Very true, still terrifying though. I wonder if the reputation of C might not cause a selection bias towards the type of developer that can hack it though. Anyway, this is definitely a solid move.


What, specifically, is horrifying, though? It's not C. It's not C++. It's not ASM. You're not going to accidentally implement a buffer overflow, you're not even going to accidentally stomp on Ruby stuff. You might find the Rust language itself intimidating but I'm not seeing what's scary about the integration itself.


I actually wrote the start of a book (it's about 50 pages) specifically on this topic.

This kind of thing was something I had on my plate to try, glad someone has already tackled it!


Very cool. Same for Python, pretty please? :-)


IIUC, it's a standard FFI call; you should be able to use such a Rust extension in any language with standard FFI conventions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: