How "mandatory" is PolyglotEngine?

Stefan Marr java at
Mon Apr 25 19:12:59 UTC 2016

Hi Peter:

> On 25 Apr 2016, at 20:58, Peter Niederwieser <peter at> wrote:
> 1. Is it OK to interact directly with `MyTruffleLanguage` (which extends `TruffleLanguage`), or do I always have to go through `PolyglotEngine`? (The latter seems more complicated, less flexible, and seems to do a lot of wrapping.)

If you don’t want to use any other Truffle-based languages, I would expect it to be fine.
My understanding is that the PolyglotEngine is not supposed to be mandatory.

Could you give examples for what you like to do, and were you found it to be insufficient?
The design is somewhat driven by the know use cases.

> 2. Say I get back an instance of `MyTruffleObject` (which implements `TruffleObject`) from `PolyglotEngine`. Is it OK to get a `CallTarget` from that instance (assuming it offers an API for that), and call that directly? Or do I always have to go through a `TruffleObject` message send instead?

It depends on what you want to do.
If this is for interactions at the boundary of Java and Truffle, it should be fine. Otherwise, the messages are better, because they are meant to allow the partial evaluation to compile out their overhead.

> If `PolyglotEngine` is not mandatory, are there nevertheless good reasons to use it when all I want is to interact with my own language?

If you want to use the REPL, the debugger, the Truffle profiler, or any of the other things built on the Instrumentation API, you’ll have to use the PolyglotEngine at the moment.

Best regards

Stefan Marr
Johannes Kepler Universität Linz

More information about the graal-dev mailing list