What’s New in GraalVM Languages

Alina Yurenko
graalvm
Published in
5 min readJun 13, 2023

Since we have so many updates in this release, we have two release blog posts: this one focuses on GraalVM languages and Truffle updates; for what’s new in GraalVM JDK and Native Image, please navigate to the related blog post.

Oracle GraalVM

We are introducing a new distribution — Oracle GraalVM! It’s available under the GraalVM Free Terms and Conditions (GFTC) license (also see the FAQ). For a user, this means the following:

  • Free for development and production use;
  • Easy download via command line or scripts for integration into CI/CD pipelines
  • Long-term support releases aligned with Oracle JDK

Read more about Oracle GraalVM and what it brings in the related blog post.

What’s new in GraalPy 🐍

GraalPy on Windows

GraalPy now works on Windows!🎉 You can build and run basic workloads on Windows, either standalone, or embedded in Java. To get started, follow our guide.

Standalone Python Applications

With GraalPy, you can now distribute Python applications or libraries as standalone binaries or JAR files without any external dependencies. The Truffle framework on which GraalPy is built, and the Sulong LLVM runtime that GraalPy leverages for managed execution of Python’s native extensions, enable virtualization of all filesystem access of Python applications, including those to the standard library and installed packages.

So now you can build a standalone executable as follows:

graalpy -m standalone binary --module my_script.py --output my_binary

or a JAR file that runs on GraalVM and includes GraalPy as follows:

graalpy -m standalone java --output-directory MyJavaApplication --module my_script.py

Compatibility and Performance

  • We added a new implementation of our Python C API interface, that uses fully native execution by default. This improves performance and compatibility with some extensions that spend a lot of time in native code, but can have negative effects in workloads that cross frequently between Python and native code. There are new options to control how extensions are built and run: python.NativeModules and python.UseSystemToolchain. The new default is to use the host system’s toolchain for building extensions instead of the LLVM toolchain that ships with GraalVM, and to run all modules natively.
  • To get an idea of GraalPy performance, take a look at the updated numbers on our GraalPy page. They are based on the community’s pyperformance benchmark suite, so you can easily compare those numbers across implementations.
Geomean speedup of GraalPy over CPython on the Python Performance suite
  • We updated numpy and pandas versions, added support for scipy and scikit_learn with ginstall.
  • We updated the language version and standard library to 3.10.8, making it compatible with more recent modules and packages.
  • We added initial support for asyncio. While not complete, this already allows some async libraries such as aiofiles to work.
  • We added a GraalPy plugin for virtualenv as a builtin module, so creating virtual environments with virtualenv on GraalPy works out of the box.

TruffleRuby

TruffleRuby was updated to Ruby 3.1.3; also foreign big integers are now supported and work with all Numeric operators.

We’ve also made several changes to improve performance:

  • Use the system libyaml for psych which improves warmup when parsing YAML.
  • Marking of native structures wrapped in objects is now done on the C call exit to reduce memory overhead.
  • Optimized splitting (copying) of call targets by implementing cloneUninitialized().
  • Process.pid is now cached per process like $$.

See more TruffleRuby updates in this release in the project changelog. We are also grateful to Shopify for many contributions to this release.

GraalJS and Node.js

We updated Node.js to version 18.14.1. We also added BigInteger interoperability support. Note that foreign BigIntegers require an explicit type cast using the BigInt function to opt into JS BigInt semantics. The default semantics is to treat all foreign numbers like JavaScript Number values, regardless of their original value or type. We also implemented several new ECMAScript proposals — see all changes in the project changelog.

Polyglot Sandboxing

GraalVM enables Java applications to run code written in other languages (guest code) via the Polyglot Embedding API. With this new release, you can now set a sandbox policy to restrict permissions for the guest code. There are several use cases which benefit from polyglot sandboxing:

  • Execution of third-party dependencies;
  • User plugins;
  • Server scripting.

You can choose among the following policies:

  • trusted: intended for guest code that is entirely trusted; it’s also the default mode.
  • constrained: enforces regulated access to host resources. For example, it disallows host file and socket access.
  • isolated: provides deeper isolation between host and guest code for more resilience — guest code executes on a separate heap with its own garbage collector and JIT compiler.
  • untrusted: intended for untrusted guest code. The sandbox employs additional hardening mechanisms at the compiler and runtime level to mitigate e.g. speculative execution attacks.

At the moment polyglot sandboxing is available for JavaScript, and we plan to add more languages in upcoming releases. Learn more about it in our guide.

Truffle Language and Tool Implementations

We implemented several new features for Truffle DSL to improve performance. In particular, a new @GenerateInline annotation allows Truffle nodes to be object-inlined automatically, reducing memory footprint and improving interpreter execution speed. Please see the documentation for details and project changelog for more updates.

Polyglot Embedding

We added java.lang.BigInteger to the Polyglot Value API. By default, all host values of the type java.lang.BigInteger are now interpreted as number values (Value.isNumber()). Note that the language support for interpreting numbers that do not fit into long values may vary. Some languages, such as JavaScript, may require explicit conversions of host big integers. Other languages, such as Ruby or Python, can use big integers without explicit conversion. The same applies to values passed across guest languages.

Conclusion

We want to take this opportunity to thank our community for all the feedback, suggestions, and contributions that went into this release. If you have additional feedback on 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.

Now go ahead and try the new GraalVM!🚀

— the GraalVM team

--

--

Alina Yurenko
graalvm

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