Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 19 the leading edge and produces a specialized version of the interpreter specifically for the given program It does this by attaching to the tree nodes the profiling and type information gathered at execution time Then Trufle can speculatively optimize the program by using this profile Trufle needs a runtime with a compiler aware of the partial evaluation and Graal fits this requirement nicely There are plenty of examples of Trufle based languages from which to take inspiration You can look at the JavaScript engine an LLVM bitcode interpreter a Ruby implementation a Python implementation and an R implementation and these are just the oficial projects by the GraalVM team You can find several other implementations of programming languages on the GitHub page There is even a demo programming language that was created to demonstrate and teach the features of Trufle which can get you started if you want to experiment The best part of Trufle languages is that at runtime all the interpreters are using the same interoperability protocol for objects in diferent programming languages which means that from the runtimes point of view there is no diference whether the program be written in JavaScript Python Ruby any other implemented language or a mix of those The runtime is able to optimize polyglot programs written in diferent languages the same way it optimizes code normally without any performance overhead for crossing the language All the programs that run on the JDK are supported by GraalVM barrier This aspect opens the door to using libraries and modules from all ecosystems and truly picking the best programming language to focus on solving the problems you need to solve rather than trying to reimplement the missing piece of functionality in the language of your project Another benefit of Truffle is that it virtualizes the language implementation so from the runtime point of view all languages look similar This is an excellent opportunity for the tooling to become polyglot as well For example you can use the JavaScript debugger to step through a Ruby program or use VisualVM to analyze the memory use of a JavaScript program just as youd normally use them for JavaScript and Java programs
You must have JavaScript enabled to view digital editions.