5 ms·
What would it require the whole Ruby to move to Rust from C? What would it bring and would it make sense?
by diminish 10y ago
What would it require the whole Ruby to move to Rust from C? What would it bring and would it make sense?
- snuxoll 10y agoA lot of time and probably breaking every native extension. It would probably give us a less buggy VM and GC, but I'm not sure it would be worth the effort to essentially rewrite the entirety of ruby in rust.
- chrisseaton 10y agoIn case you are thinking it would make Ruby significantly faster, I don't see how it would. Ruby is slow due to a lack of caching and dynamic compilation and optimisation, not due to basic interpreter code being slow because it's written in C. I can't see how Rust's parallelism model would help either. Maybe it would prevent some bugs that Ruby currently has? I don't see Ruby as having a problem with bugs though - certainly not that would make it worthwhile to do a translation.
- cm3 10y ago> I can't see how Rust's parallelism model would help either. I'm unaware of a Rust parallelism model. Care to explain?
- azdle 10y agoI'd assume GP is referring to something like http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.ht... Which is not a parallelism model itself, but is more about how rust's data model lends itself to implementing different kinds of parallelism in a reliable way.
- rubiquity 10y agoProbably a lot of work. It would bring the same things that most rewrites do: Cleaner code in most places and probably some performance due to understanding problems better the second time around. If you were doing the rewrite for performance, it wouldn't be worth it. If you were doing the rewrite for a more modern language to attract more contributors, it might be worth it. I don't think Ruby as a language has had many issues in the space that Rust tends to solve (safety related to memory). Ruby is garbage collected. I don't know what (if any) performance boost the VM would get by being converted to LLVM IR. It's mostly the semantics of Ruby the language that make it hard to make fast. It seems most of the recent efforts to make Ruby faster have been by making the runtime do less allocations.
- chrisseaton 10y ago> I don't know what (if any) performance boost the VM would get by being converted to LLVM IR Well you can already convert the VM to LLVM IR today by compiling with clang.
- valarauca1 10y agoThis is an interesting idea. If you transpile the Ruby runtime to LLVM-IR you can run Ruby's IR in LLVM's tracing JIT mode. Theoretically the LLVM will optimize your application as its running. P.S.: I don't know Ruby so YMMV P.P.S.: If it works with Ruby it'll work with Python too.
- chrisseaton 10y agoWe do this to run Ruby C extensions on the JVM - compile the extension to LLVM IR instead of native code, then JIT compile the IR using the JVM's JIT. It's fast!
- chc 10y agoHuh? You use the JVM's JIT to compile LLVM IR? How does that work? Isn't it a bytecode compiler?
- chrisseaton 10y agoWell yes but at some point in the pipeline the byte code is long gone. So you can use it for anything by using just the parts beyond that point. But really we don't directly compile the IR. We have an interpreter for IR, and we JIT compile the interpreter, sort of constant folded with the IR. It achieves the same thing without getting more technical. https://github.com/graalvm/sulong https://github.com/graalvm/sulong
- rubyfan 10y ago>If you were doing the rewrite for a more modern language to attract more contributors, it might be worth it. Can you explain how a relatively less mature and less widely adopted "modern" language is going bring more contributors to MRI?