TruffleRuby Status
lists.ruby-lang.org
lists.ruby-lang.org
"JRuby+Truffle started as my internship project at Oracle Labs in early 2013. It is an implementation of the Ruby programming language on the JVM, using the Graal dynamic compiler and the Truffle AST interpreter framework. JRuby+Truffle can achieve peak performance well beyond that possible in JRuby at the same time as being a significantly simpler system. In early 2014 it was open sourced and integrated into JRuby."
via http://chrisseaton.com/rubytruffle/
I've used JRuby for a while, but I hadn't heard of Truffle
The JVM is an exciting place to be right now.
That's blazingly fast! The missing part now is C extension support and they seem confident to be able to deliver this.
Color me impressed.
Wasn't part of truffle's point and advantage that it would interpret and JIT C code alongside Ruby code and optimise across the boundary? Is the missing part just the declaration of the MRI API on the C-side, or is it pre-compiled (and thus not interpretable) C extensions?
Compilers are cool.
We work on the C source code (actually the LLVM bitcode) rather than compiled C extensions, yes.
Ah OK, I guess I remember the 2015 news and thought it a "done deal" rather than a POC/WIP. Thanks.
The jruby ecosystem is extremely mature and production ready. For example, database connectors exist which are pure java rather than based on c extensions. They may be better as well. Same goes for ssl (https://github.com/jruby/jruby-openssl/blob/master/README.md) and xml parsing (https://github.com/YorickPeterse/oga/blob/master/README.md)
Also goes for all the json parsing, etc stuff which seems to need c extensions. Lots of systems stuff is perfectly workable using jruby (https://github.com/minimagick/minimagick/blob/master/README....)
This would be a different story if you were doing jython fof example - python does not have a viable java based ecosystem.
If I were you, i would NOT focus on c extensions and instead work on other stuff (like startup speed)
Both types of extensions are hard because they're written against an API which is just the entire internals of their implementations. If you don't use the same internals it's very hard to meet that API.
This explains in depth https://www.youtube.com/watch?v=YLtjkP9bD_U
Is there an HN reader app that does it? or just HN jargon?
The Graal/Truffle/Sulong stack is pretty amazing, being able optimize through the ruby/C boundary is crazy. Really looking forward to see what comes out of that work this year and beyond.
Does the ability to use Java libraries with TruffleRuby go away with SubstrateVM though?
I really like the idea of TruffleRuby becoming its own super fast Ruby implementation unhindered by the need to provide the same feature set as JRuby.
A limitation of the SubstrateVM build is you can't just start calling code in a JAR you load at runtime -- that needs to be built into the image. A common use case for JRuby is as a really awesome shell to Java. You won't have that capability with SubstrateVM because we can't load arbitrary Java code at runtime. Likewise, you couldn't just swap out JARs with different implementations of interfaces on the fly (e.g., JDBC usage patterns). And JRuby can load gems that themselves have Java code in them, which also wouldn't work (setting aside the fact we also don't support their extension API).
I was considering the case of building a single executable, including the entire ruby application and its dependencies, via SubstrateVM. This could make deployment a lot simpler.
I'm thinking of Shenandoah specifically.
I understand they depend on inserting barriers with JVMCI, so I'm hopeful for compatibility. How is SubstrateVM build? It is made out of using the OpenJDK code base in a specific manner?
I think that the best practice for C extensions when used for performance is that Gems have both a pure Ruby reference implementation and a C extension. This means all implementations can run them and more people can read the code. OilyPNG and PSD Native do this and it's been extremely helpful to my research.
C extensions, even when run in our interpreter, tend to run faster than Ruby code because C has simpler semantics and needs fewer guards (checks) when running code.
I haven't done a careful comparison of C extension performance compared to Ruby performance when both are running on Graal. I should do that.
Pure Java is pretty fast, and an existing library has the advantage of not just already being around, but probably being battle-tested.
30 Comments which means HN as a community has lost interest in Ruby.
A signal that Ruby is dying? ( Or in maintenance mode, or not growing, which ever you may prefer to word it ) Only Last week someone replied to me on HN that their areas dont have any Open Jobs for Ruby Devs.