JAX London 2023: "When Is Native Java With GraalVM Worthwhile for Me?"
Summary
- For most users, native Java was not worthwhile at the time.
- Java was more expensive because it was tuned for long-lived, big applications.
- Java’s new competition was JavaScript & Python.
- We could make Java cheaper: with CDS, CRaC, and GraalVM.
- GraalVM gave us faster startup, less memory use, smaller files, and better security.
- In my sample application, going from Spring Boot 2.7 to Quarkus 3 reduced the startup time from 589 ms to 10.4 ms and the initial memory allocation from 107 MB to 5.6 MB.
- I only recommended GraalVM for microservices, not for monoliths or serverless.
My slides showed why I came to this conclusion.
Logistics
Conference
JAX London 2023 was the second-largest Java conference in the UK and a hybrid conference. It ran from October 2 through October 5, 2023.
Talk
My talk took place on October 4, 2023, at 11:45.
Abstract
Many Java apps were migrating to the cloud. Yet, on the cloud, Java was frequently more expensive than alternatives such as Go. Native Java using the static GraalVM Native Image AOT (Ahead-of-Time) compiler reduced the cost of Java. Native Java became popular because frameworks such as Quarkus and Micronaut, and Spring Boot 3.0, provided it a significant boost. Did I have to learn a new framework, such as Quarkus or Micronaut? How did native Java function? And when would it be worthwhile for me to learn native Java? These were the topics of my presentation.
Who Made Me the Expert?
In the spring of 2022, I was the editor of a highly popular, six-part article series about native Java on InfoQ. I had data to back up my claims. And Java experts helped me.
Unlike some other talks, which were either pro or against GraalVM Native Image, I was neutral on it. I was the Switzerland of GraalVM talks! Which was quite fitting, as my project at the time was in Switzerland! 😃 I wasn’t selling books or training courses, and I wasn’t a developer advocate. I shared my experiences and my knowledge so you could get better projects faster!
Slides
The slides were available as a PDF. They had more content and more text than my talking slides. They were just 1.3 MB:
Historical note (as of October 2023): Back then, the slides were also available in their original Keynote format (36.7 MB) — with less text, but animated and with speaker notes; that file is no longer available today.
Get Started With Native Java
My guide to getting started with native Java explained how to install the tools for Spring Boot 3 and Quarkus, how to build native executables, and went into more detail on how Java and GraalVM worked.
Additional Talk Information
Popularity of JavaScript & Python
Historical note (as of October 2023): The following popularity data came from my “Java Tech Popularity Index Q3/2023” and reflected the state of things at the time — including the job ad and Udemy student numbers I measured for that index.
Google Searches
Google Trends demonstrated the initial interest in a technology over time (chart link). “More searches = better” to me. The percentage behind the current value was the drop-off from the peak value, marked with a circle.
Here are searches for the languages that competed with the JVM (chart link):
Here are the same JVM competitors over the last three years:
This link produced the chart above.
Python won, JavaScript was second, Java was third, C# was fourth, and Go was fifth. All languages had declined since early to mid-2022. Python had grown about 18% over the previous three years but only led JavaScript 1.4:1. After being neck-to-neck with Java, JavaScript was now slightly ahead. C# had only 37% of JavaScript’s search volume and hadn’t gained share over the previous three years. Go gained slightly against C#.
Stack Overflow Questions
We could run database queries against the questions, answers, and comments at Stack Overflow with the StackExchange Data Explorer. The number of monthly questions was a proxy for using a technology during evaluation and productive use. “More questions = better” to me. The percentage behind the current value was the drop-off from the peak value, marked with a circle.
Here are the shares of questions for the languages that competed with the JVM:
Python won, JavaScript was second, Java third, C# fourth, TypeScript fifth, and Go sixth. This was a chart of significant decline: Python, JavaScript, and Java had declined massively and in sync since early 2020. Python still led JavaScript 1.5:1 but had only 39% of its peak value from early 2020 — a loss of 49% since November 2022. At 33% of its 2016 peak, JavaScript led Java 1.7:1; it had also lost 49%, but since August 2022. C# had gained on Java since 2022 and reached 83% of Java’s questions. TypeScript’s seven-year rise had ended mid-2022, leaving it at two-thirds of Java’s questions. Go had been low and steady for about seven years, reaching only 11% of Java’s numbers.
Note that the overall monthly number of Stack Overflow questions was down 42% since ChatGPT appeared (November 2022 vs. August 2023):
You could run the queries below at the StackExchange Data Explorer. I used two queries to get the number of monthly questions for the JVM competitors because putting all of them in one query timed out.
Query: Java, JavaScript, and TypeScript
DECLARE @StartDate DATE = '2009-01-01';
DECLARE @EndDate DATE = '2023-06-30';
WITH Tagged AS (
SELECT
Id,
CreationDate,
CASE WHEN CHARINDEX('<java>', Tags) > 0 THEN 1 ELSE 0 END AS JavaTag,
CASE WHEN CHARINDEX('<javascript>', Tags) > 0 THEN 1 ELSE 0 END AS JavascriptTag,
CASE WHEN CHARINDEX('<typescript>', Tags) > 0 THEN 1 ELSE 0 END AS TypeScriptTag
FROM Posts
WHERE
PostTypeId = 1 AND -- 1 for
CreationDate >= @StartDate AND
CreationDate <= @EndDate
),
MonthlyCounts AS (
SELECT
DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) AS Month,
SUM(JavaTag) AS Java,
SUM(JavascriptTag) AS Javascript,
SUM(TypeScriptTag) AS TypeScript
FROM Tagged
GROUP BY DATEADD(month, DATEDIFF(month, 0, CreationDate), 0)
)
SELECT
Month,
Java,
Javascript,
TypeScript
FROM MonthlyCounts
ORDER BY Month;
Query: C#, Go, and Python
DECLARE @StartDate DATE = '2009-01-01';
DECLARE @EndDate DATE = '2023-06-30';
WITH Tagged AS (
SELECT
Id,
CreationDate,
CASE WHEN CHARINDEX('<c#>', Tags) > 0 THEN 1 ELSE 0 END AS CsharpTag,
CASE WHEN CHARINDEX('<go>', Tags) > 0 THEN 1 ELSE 0 END AS GoLangTag,
CASE WHEN CHARINDEX('<python>', Tags) > 0 THEN 1 ELSE 0 END AS PythonTag
FROM Posts
WHERE
PostTypeId = 1 AND -- 1 for
CreationDate >= @StartDate AND
CreationDate <= @EndDate
),
MonthlyCounts AS (
SELECT
DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) AS Month,
SUM(CsharpTag) AS Csharp,
SUM(GoLangTag) AS GoLang,
SUM(PythonTag) AS Python
FROM Tagged
GROUP BY DATEADD(month, DATEDIFF(month, 0, CreationDate), 0)
)
SELECT
Month,
Csharp,
GoLang,
Python
FROM MonthlyCounts
ORDER BY Month;
CDS
My guide to getting started with native Java had details on starting with Class Data Sharing.
CRaC
My InfoQ news item has details on CRaC and an interview with Simon Ritter from Azul, the driving force behind CRaC. My guide to getting started with native Java also went into more detail on CRaC.
GraalVM
Here is the announcement of Oracle GraalVM for Java 21. The release was on September 19, 2023, the same day that Java 21 got released.
Demo Application
The demo application converted images to PDFs. It was available for Spring Boot 2 & 3, Quarkus, and Go.
Check out the demo application
Java in Serverless
Here’s Holly Cummins during her Devoxx UK 2023 keynote, citing the serverless market share statistics: