Designing an intuitive language-agnostic integration of foreign objects in Ruby
GraalVM enables all Truffle languages to interoperate with each other and call each other, through a set of traits exposed in Truffle’s InteropLibrary
. There are many such traits: array elements, hash entries, buffer elements, executable, instantiable, members, iterator, iterable, exception, pointer, meta object, source location, identity, number, string, boolean, etc. This interoperability API is probably the richest available today, but it needs to be integrated deeply in languages so that it is natural to use and does not require special calls or constructs to deal with foreign objects. As a simple example, foreign_array[index]
should just work, and not require something like Interop.read_array_element(foreign_array, index)
. As something more advanced we want all Ruby Array methods, such as map
to also be available on foreign arrays.
In this talk we explore how to integrate foreign objects fully into the GraalVM Ruby implementation, TruffleRuby. This means we want foreign objects to behave exactly the same as Ruby objects, to have the same methods, to be given a Ruby class, to use the Ruby class hierarchy, etc. By giving them a Ruby class, we are able to define methods for foreign objects as regular Ruby methods, in Ruby code. Foreign objects can also be extended with new methods by the user, just like it is possible to add methods to any Ruby class at runtime. We hope this deep integration makes it easier to use the polyglot nature of GraalVM, and we hope the design in TruffleRuby inspires other Truffle languages to adopt a similar approach.
Researcher at Oracle Labs, interested about parallelism in the context of TruffleRuby, an implementation of Ruby using the Truffle framework and the Graal dynamic compiler.
Tue 7 JunDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
11:00 - 12:30 | |||
11:00 30mShort-paper | Efficient Object Graph Recording with Truffle for Live Data-Structure Programming Truffle Shusuke Takahashi Tokyo Institute of Technology, Yusuke Izawa Tokyo Institute of Technology, Hidehiko Masuhara Tokyo Institute of Technology, Youyou Cong Tokyo Institute of Technology Media Attached | ||
11:30 30mTalk | Designing an intuitive language-agnostic integration of foreign objects in Ruby Truffle Benoit Daloze Oracle Labs Pre-print Media Attached | ||
12:00 30mTalk | Embedding Truffle Languages Truffle Kevin Menard Shopify Media Attached |