17 Şubat 2022 Perşembe

GraalVM Truffle - Polyglot Runtime

Giriş
Bu bileşen aynı zamanda Espresso Project olarak ta biliniyor. Açıklaması şöyle. Yani GraalVM iki şekilde kullanılabiliyordu. 
1. Ya Native Image oluşturuluyor 
2. Ta da kendi içinde barındırdığı Java HotSpot VM için JIT yapıyordu. 

Artık JVM olarak ta kullanılabilir
Up until now, GraalVM has offered two ways to run Java programs: using the Java HotSpot VM with the GraalVM JIT (just-in-time) compiler, and compiled to a native executable using GraalVM Native Image.

Today, we’re happy to announce a new way to run Java on GraalVM. GraalVM 21.0 introduces a new installable component, named espresso, which provides a JVM implementation written in Java.
Açıklama şöyle. Yani Truffle diğer dilleri de çalıştırabiliyor
One of the newer VMs is GraalVM. I'm not sure it's completely correct to call it a JVM because it can (supposedly) also run other languages such as Python, Ruby, C, and C++.
Espresso bileşeni "Truffle Language Implementation Framework" kullanılarak yazılmış bir JVM. Şeklen şöyle
Şeklen şöyle


Bazı yeni özellikler şöyle
Java on Truffle enables some interesting use cases. You can embed Java bytecode of a different version in your main Java application (given you have both distributions), dynamically execute Java code in native executable built with Native Image, use it for advanced class redefinition, get access to all Truffle tools and interoperability, and more.

Over the year we’ve done a lot of work on Java on Truffle in terms of both features, like the new Hotswap Plugin API, which allows reloading the code without the need for restarting a running application, and performance — most recently on startup performance in a wide range of benchmarks. Stay tuned for more updates in 2022!
Truffle Artık Ayrıca İndirilebiliyor
Açıklaması şöyle
GraalVM’s polyglot language runtime, Truffle, and language runtimes are now decoupled from the GraalVM JDK. Standalone language runtimes are available for download in native and JVM standalone versions. For embedding in Java applications, you can download all artifacts from Maven Central, which will work for GraalVM JDK and any other compatible JDK.
Polyglot Embedding
Açıklaması şöyle
Previously, to embed GraalVM languages in Java applications, you had to install them using the gu tool. Now all languages are available as Maven dependencies. 
Örnek
Java içinde Python kullanmak için şöyle yaparız
<dependency>
  <groupId>org.graalvm.polyglot</groupId>
  <artifactId>polyglot</artifactId>
  <version>23.1.0</version>
</dependency>
<dependency>
  <groupId>org.graalvm.polyglot</groupId>
  <artifactId>python</artifactId>
  <version>23.1.0</version>
  <type>pom</type>
</dependency>
Örnek
Java içinde Javascript kullanmak için şöyle yaparız
<dependency>
  <groupId>org.graalvm.polyglot</groupId>
  <artifactId>js</artifactId>
  <version>23.1.0</version>
  <type>pom</type>
</dependency>


Hiç yorum yok:

Yorum Gönder