Supercharge Your Applications with GraalVM — Book

A B Vijay Kumar
5 min readMay 21, 2021

It’s been a long gap, since I blogged. Packt reached out to me, after reading my blog, and offered to convert the content into a more details hands on book.

It's been a super exciting, learning experience writing the book.

Before I explain what is gone into this book, let me introduce GraalVM. Here are some blogs on GraalVM, I had published before.

Episode 1: “The Evolution” — Java JIT Hotspot & C2 compilers (the current episode…scroll down)

Episode 2: “The Holy Grail” — GraalVM

In this blog, I will talk about how GraalVM embraces polyglot, providing interoperability between various programming languages. I will then cover how it extends from Hotspot, and provides faster execution, and smaller footprints with “Ahead-of-time” compilations & other optimisations.

Java Serverless on Steroids with fn+GraalVM Hands-On

This blogs provides a hands on example of how to build a serverless application using fn project and run it on GraalVM

GraalVM is a universal virtual machine that allows programmers to embed, compile, interoperate, and run applications written in JVM languages such as Java, Kotlin, and Groovy; non-JVM languages such as JavaScript, Python, WebAssembly, Ruby, and R; and LLVM languages C and C++.

GraalVM provides an Graal Just-in time (JIT) compiler, an implementation of JVMCI (Java Virtual Machine Compiler Interface), which is completely built on Java and uses Java Just in Time compiler (C2 compiler) optimization techniques as the baseline and builds on top of it. Graal JIT is much more sophisticated than Java C2 JIT compiler. GraalVM is a drop-in replacement with JDK, which means that all the applications that are currently running on JDK, should run on GraalVM without any application code changes.

GraalVM also provides Ahead-of time (AOT) compilation to build native image, with static linking. GraalVM AOT helps build native image, that have a very small footprint, faster startup and execution, which is ideal for the modern day microservices architectures.

While GraalVM is built on Java, it not only supports Java, but also enables polyglot development with JavaScript, Python, R, Ruby, C, and C++. It provides an extensible framework called Truffle, that allows any language to be built and run on the platform.

GraalVM is becoming a default runtime for running cloud native Java microservices. Soon, all Java developers will be using GraalVM to run their cloud native Java microservices. There are already a lot of Microservices Frameworks that are emerging in the market such as Quarkus, Micronaut, Spring native etc, that is built on GraalVM

Developers working with Java will be able to put their knowledge to work with this practical guide to GraalVM and Cloud Native Microservices Java Frameworks. The book provides a hands-on approach to implementation and associated methodologies that will have you up-and-running, and productive in no time. The book will provide step-by-step explanations of essential concepts with simple and easy to understand examples.

This book would be a hands-on guide for developers who wish to optimize their apps’ performance and are looking for solutions. We will start by giving a quick introduction to GraalVM architecture and how things work under the hood. Developers would quickly move on to build explore the performance benefits they can gain by running their Java applications on GraalVM. We’ll learn how to create native images and understand how AOT can improve application performance significantly. We’ll then move on to explore examples of building polyglot applications and explore the interoperability with between languages, running on the same VM. We’ll explore Truffle framework to implement our own languages to run optimally GraalVM. Finally, we’ll also learn how GraalVM is specifically beneficial in cloud-native and microservices development

Who this book is for?

The primary audience would be Java developers looking to optimize their application’s performance. This book would also be useful to Java developers who are exploring options to develop polyglot applications by using tooling from the Python/R/Ruby/Node.js ecosystem. Since this book is for experienced developers/programmers, readers must be well-versed with basic software development concepts and should have decent knowledge writing java code.

What this book covers

Chapter 1, History of JVM

This chapter will walk through the evolution of JVM, and how it optimized the interpreter and compiler. It will walk through C1, C2 Compilers, the kind of code optimizations that the JVM performs to run Java programs faster.

Chapter 2, JIT, HotSpot and Graal

This chapter does a deep dive on how JIT compilers and Java Hotspot works and how it JVM optimizes the code at runtime

Chapter 3, GraalVM Architecture

This chapter provides the architecture overview of Graal and the various architecture components. The chapter goes into details on how GraalVM works and how it provides a single VM for multiple language implementations. This chapter also covers the optimizations GraalVM brings on top of Standard JVM

Chapter 4, Graal Compiler — Just in Time

This chapter talks about Just in Time compilation option of Graal VM. It will go through in detail about the various optimizations Graal Just in Time compiler performs. This is followed by a Hands-on tutorial to use various compiler options to optimize the execution.

Chapter 5, Graal Compiler — Ahead of Time

This chapter is a hands-on tutorial, that walks through how to build native images and optimize and run these images, with Profile Guided Optimization techniques.

Chapter 6, Truffle

This chapter introduces the Truffle Polyglot Interoperability capabilities and high-level framework components. This will also cover how data can be transferred between applications, that are written in different languages, that are running on GraalVM

Chapter 7, Graal Polyglot (JavaScript and Node)

This section introduces the JavaScript and NodeJS. This is followed by a tutorial on how to use Polyglot API for interoperability JavaScript and NodeJS application

Chapter 8, Graal Polyglot (Python, R and Java on Truffle)

This section introduces the Python, R and Java Truffle (Espresso). This is followed by a tutorial on how to use Polyglot API for interoperability between various languages.

Chapter 9, Graal Polyglot (LLVM, Ruby, WASM)

This section introduces the JavaScript and NodeJs. This is followed by a tutorial on how to use Polyglot API to interoperate between an example JavaScript and NodeJS application

Chapter 10, Microservices and Serverless Architecture, Frameworks (Micronaut, Quarkus, fn Project) with Case Study

This chapter covers the modern MicroServices Architecture and how the new frameworks such as Quarkus and Micronaut implement Graal for most optimum Microservices architecture

The book is scheduled to release in June 2021, and open for pre-order. You can find the book at

--

--

A B Vijay Kumar
A B Vijay Kumar

Written by A B Vijay Kumar

IBM Fellow, Master Inventor, Mobile, RPi & Cloud Architect & Full-Stack Programmer

Responses (2)