Why does truffleruby need C extensions?

454 views Asked by At

Current status of truffleruby says:

TruffleRuby is progressing fast but is currently probably not ready for you to try running your full Ruby application on. Support for critical C extensions such as OpenSSL and Nokogiri is missing.

Why does truffleruby need C extensions? It's built on GraalVM which is built on top of the JVM, it is in fact a fork of JRuby:

TruffleRuby is a fork of JRuby, combining it with code from the Rubinius project, and also containing code from the standard implementation of Ruby, MRI.

Can't they use JRuby world gems instead of depending on their C variants?

EDIT link to the issue on github

2

There are 2 answers

8
Chris Seaton On BEST ANSWER

Running C extensions is hard because the C extension API is just the entire internals of MRI exposed as a header file. You aren't programming against a clean API - you're programming against all the implementation details and internal design decisions of MRI.

JRuby's Java extensions have exactly the same problem! The JRuby Java extension API is just the entire internals of JRuby, and you aren't programming against an API, instead you're programming against all the implementations details and design decisions of JRuby.

We plan to eventually tackle both problems in the same way - which is to add another level of abstraction over the C or Java code using an interpreter which we can intercept and redirect when required, so that it believes it is running against MRI or JRuby internals, but really we redirect these to our internals.

We think C extensions are more important, so we're tackling those first. We haven't really started on Java extensions yet, but we have started the underlying interpreter for Java that we'll use.

This video explains all

https://youtu.be/YLtjkP9bD_U?t=1562

2
Jörg W Mittag On

You have already gotten a good answer by the project lead himself, but I want to offer a different point of view:

Why does truffleruby need C extensions?

It doesn't need them. But they do exist and there is code out there which uses them, and it would sure be nice to be able to run that code.