Type hierarchy

Renze Torensma renzetorensma at gmail.com
Tue Apr 7 15:01:10 UTC 2015


I don’t think I have time to attend, but it sounds great!


> On 2 apr. 2015, at 15:10, Chris Seaton <chris.seaton at oracle.com> wrote:
> 
> We’ve learned a lot through integrating Truffle into JRuby - it’s such a large mature code base, with many real users, and the Ruby language itself is also very large. We had exactly the same problem as you - IRubyObject is used  everywhere in JRuby.
> 
> I hope to be at the Truffle Workshop at ECOOP this year http://2015.ecoop.org/track/Truffle-2015-papers <http://2015.ecoop.org/track/Truffle-2015-papers> where I can say a lot more about the challenges and opportunities of integrating Truffle into an existing language.
> 
> If you’re trying to do the same we’d love to have you there - there is the potential for financial assistance for people to attend and you can present your plans as a starting point for discussion.
> 
> In the mean time you can contact me on Skype chrisgrahamseaton or on #jruby IRC if you want some more info about our experience.
> 
> Chris
> 
>> On 2 Apr 2015, at 14:01, Renze Torensma <renzetorensma at gmail.com <mailto:renzetorensma at gmail.com>> wrote:
>> 
>> Hi Chris,
>> 
>> Thanks for your answer! I asked this because I have an existing code base for a language and I want to use Truffle to speed it up. Comparable to JRuby I think, but it’s just a research project so not used in production. And if I want to use Java primitives I have to change a lot of code, because the Value superclass is used all over the code base.
>> 
>> I’m going to think about it a bit more and hopefully come up with a good solution :)
>> 
>> Renze
>> 
>>> On 1 apr. 2015, at 15:59, Chris Seaton <chris.seaton at oracle.com <mailto:chris.seaton at oracle.com>> wrote:
>>> 
>>> Hello Renze,
>>> 
>>> In the past when people have developed JVM languages like Jython and JRuby they have recreated the guest language’s class hierarchy in Java. So in JRuby, there is a RubyBasicObject, a RubyObject and a RubyFixnum. These Java classes have methods that correspond to the Ruby methods in the same classes.
>>> 
>>> I would not recommend doing this for a Truffle language. I think instead you want to increase the level of abstraction slightly and think more about writing a Java program that represents the guest language object model, rather than recreating it in Java.
>>> 
>>> In the Truffle implementation of Ruby, we use int and long for Fixnum, even though they logically extend Object and BasicObject, and there is no RubyFixnum class at all. We then add special cases for all operations that examine the class of an object to return that Fixnum is the class for an int or long - we abstract the inheritance and express it in Java code, rather than expressing it using the Java object model.
>>> 
>>> To take it one stage further you can use a Truffle DyanmicObject to represent your guest language objects.
>>> 
>>> Combining all of this - not using the Java class hierarchy, not writing methods in your guest language classes, and then using DyanmicObject instead, in the end you’ll find you don’t have any need for classes like RubyObject at all (we still have them in JRuby+Truffle but they’re going away soon).
>>> 
>>> Is that helpful? Or do you have more specific reasons why you want the inheritance which make this not practical?
>>> 
>>> Regards,
>>> 
>>> Chris
>>> 
>>>> On 1 Apr 2015, at 14:32, Renze Torensma <renzetorensma at gmail.com <mailto:renzetorensma at gmail.com>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> Do you have any tips about dealing with a type hierarchy that has one superclass for all types? For example a Value superclass with Boolean, String, Int, List and Date subclasses. That way I can’t use the java primitives for boolean and int so I lose out on those performance gains I think..
>>>> 
>>>> Renze
>>> 
>> 
> 



More information about the graal-dev mailing list