5 ms·
Probably 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 pro
by rubiquity 10y ago
Probably 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?
- yazaddaruvala 10y agoHere is a good starting point for the discussion about, Rust increasing contributors. https://news.ycombinator.com/item?id=11156478 https://news.ycombinator.com/item?id=11156478
- rubyfan 10y agoThis is both anecdotal on observations and subjective on the assertion that rust is better than C for MRI. Also rust adoption is yet to bear out and speculation at best that rust would bring more contributors. A good comparison point might be Rubinius or JRuby to see what a non-C approach does for contribution.