What’s new in Truffle 24.0 and Graal Languages

Alina Yurenko
graalvm
Published in
5 min readMar 19, 2024

Today, along with GraalVM for JDK 22, we are also releasing a new version of Truffle and Graal languages: version 24.0. This version is designed for use with GraalVM for JDK 22, but it is also compatible with GraalVM for JDK 21 (LTS). Let’s look at what’s inside this release!

Polyglot Embedding

This is the first release since Truffle Unchained, so you can leverage the new backward compatibility feature introduced by Unchained.

In other words, you can now use this version of Truffle and Graal languages (24.0) with GraalVM for JDK 22 as well as GraalVM for JDK 21.

In the future, the latest version of Truffle and Graal languages will remain compatible with the latest version of the GraalVM JDK as well as the latest LTS release. This means that you can use the latest polyglot language features while staying on the current LTS release of the GraalVM JDK.

The following table shows compatibility for upcoming versions:

Truffle backwards compatibility (underscore indicates an LTS release)

Note that when using Truffle and Graal languages 24.0 with GraalVM for JDK 21, you will need to update to the latest version (currently 21.0.2).

We’ve also made several changes for those of you who embed other languages in your Java applications. These new features include:

  • Improved Array Access. We added the ability to use Value#as(Collection.class) to map guest language arrays (Value#hasArrayElements()) to the Java Collection interface to access the array elements without copying the guest language array. (For more information, see GitHub issue #260.)
  • Interop buffer mapping. Interop buffers are now mapped to byte[] in a host application.
  • We deprecated the FileSystems#allowLanguageHomeAccess() method and introduced FileSystem#allowInternalResourceAccess() as a replacement. To ensure compatibility, both methods now provide support for language homes and internal resources.

Learn about additional changes in the release notes and the project changelog.

GraalPy 🐍

Compatibility ✅

We are working hard to make more and more libraries available on GraalPy. In this release, we expanded support for the following: tensorflow, tensorflow-io, protbuf, llvmlite, pydantic-core, catboost, ray, readme-renderer, safetensors, keras, pybind11, grpcio, PyO3, cryptography, bcrypt, cramjam, libcst, orjson, rpds_py. Try them out, provide feedback, and let us know what other libraries you would like to run on GraalPy.

Windows compatibility is one of the most requested features from GraalPy users, and we are actively working on it. In this release, we added support to install packages with native extensions on Windows.

GraalPy on GitHub Actions 🚀

You can now use GraalPy within the setup-python GitHub Action! Configure it as follows:

    - name: Setup GraalPy
uses: actions/setup-python@v5
with:
python-version: graalpy # or graalpy24.1 to pin a version

Also, we now provide a collection of recipes in the form of GitHub Actions to build popular native extensions on GraalPy. The recipes provide a reproducible way for the community to build native extensions for GraalPy with the correct dependencies.

In other developer experience news, you can also easily try out using GraalPy from Java via JBang. You can execute scripts directly via the command line:

jbang hello@oracle/graalpython/release/graal-vm/24.0 "print('Hello GraalPy!')"

For a more advanced example of embedding Python in Java, follow our sample project.

A Java and GraalPy application running on JBang

We also switched to using the system toolchain instead of the GraalVM LLVM runtime (Sulong). This reduces the footprint in the default configuration where C extensions are run natively.

If you are an existing GraalPy user, and even more so if you are new to it, make sure you check out our GraalPy quick reference — it will help you a lot.

GraalPy quick reference

We’ve also made several changes around interoperability — read more in the release notes.

JavaScript and Node.js

We implemented several new proposals, such as those for Async Iterator Helpers, JSON.parse source text access, Well-Formed Unicode Strings, and WebAssembly threads.

Also, the WebAssembly support in Node.js is now enabled by default. You can disable it using the experimental option --js.webassembly=false.

TruffleRuby

  • C/C++ extensions are now compiled using the system toolchain and executed natively instead of using the GraalVM LLVM runtime (Sulong). This leads to faster startup, no warmup, better compatibility, smaller distribution, and faster installation for C/C++ extensions.
  • Full support for the Ruby 3.2 and Ruby 3.3 syntax (including pattern matching) by adopting the Prism parser, which is about twice as fast as the old parser.
  • See other changes in the TruffleRuby release notes.

Community and Ecosystem

  • You might know about MLE, the embedding of GraalVM in Oracle Database that enables you to run Graal languages, such as JavaScript, right in the database. A similar module for JavaScript execution is now also available in MySQL.
  • Apple recently open sourced a new configuration language Pkl. It’s built on the Truffle framework 🚀
  • You can accelerate your polyglot GraalVM applications with GPUs via TornadoVM — see how.
  • If you use IntelliJ IDEA for building polyglot applications, there’s a neat way to enable syntax highlighting for each such language via an annotation or a comment. It works with any language supported by IDEA.

Conclusion

We’d like to take this opportunity to thank our amazing contributors and community for all the feedback, suggestions, and contributions that went into this release.

If you have feedback for this release or suggestions for features that you would like to see in future releases, please share them with us on Slack, GitHub, or Twitter.

— the GraalVM team

--

--

Alina Yurenko
graalvm

I love all things tech & community. Developer Advocate for @graalvm, blog posts about programming, open source, and devrel.