Author: Karsten Silz
Sep 3, 2023   |  updated Sep 4, 2023 3 min read

Permalink: https://betterprojectsfaster.com/learn/talks-ljc-lightning-talk-2023-why-is-java-so-expensive/

Aspiring Speakers Lightning Talk: "Why Is Java in the Cloud So Expensive – And How Can I Make It Cheaper?"

Aspiring Speakers Event Invite

Summary

  • Java is expensive: It uses more RAM & CPU time than JavaScript or Go.
  • You care because JavaScript & Python are competition.
  • You can make Java cheaper with Class Sharing, CRaC, and GraalVM Native Image.

Please see my slides for why I came to this conclusion.

Information additional to the slides is below.

And here’s how to get started with GraalVM Native Image – or “Native Java”, as I call it:

Table Of Contents

Talk

The Aspiring Speakers regulary hosts online lightning talks. I’ll talk there on Tuesday, September 5, 2023 about “Why Is Java in the Cloud So Expensive – And How Can I Make It Cheaper?”.

Slides

Here are the slides as PDF. They are just 202 KB:

You can also get the slides in their original Keynote format. “Keynote” is Apple’s presentation application. Why would you do that? My slides have less text than the PDF version, so you can see what I cut. I also animated the slides, so they are more pleasant to watch. Or maybe you want to peek under the hood to see how I achieved specific effects. These slides are 3.5 MB.

Get Started With Native Java

Here’s my page for getting started with native Java.

  • It tells you how to install the tools for Spring Boot 3 and Quarkus and how to build native executables.
  • It explains in more detail how Java works and how GraalVM works.

The section is slightly out-of-date, as it doesn’t use the latest GraalVM release. I’ll update once the next GraalVM release drops in the middle of September. In the meantime, you can also read my InfoQ news item about the latest GraalVM release. It includes an interview with Alina Yurenko, developer advocate for GraalVM at Oracle Labs.

Additional Talk Information

Class Sharing

Class Sharing for OpenJDK 17 is documented here. It comes down to three steps:

  • Create class list: You create class list with -Xshare:off and -XX:DumpLoadedClassList=hello.classlist. This does not run your program, it just creates the list.
java -Xshare:off -XX:DumpLoadedClassList=hello.classlist -cp hello.jar
  • Create static archive: You now turn the class list into a static class archive.
java -Xshare:dump -XX:SharedArchiveFile=hello.jsa -XX:SharedClassListFile=hello.classlist -cp hello.jar
  • Run with static archive: Now your application can use the static archive at runtime.
java -XX:SharedArchiveFile=hello.jsa -cp hello.jar

CRaC

Please see my InfoQ news item about CRaC for information on how to get started. It includes an interview with Simon Ritter, the driving force behind CRaC.

GraalVM Native Image

I measured the GraalVM Native Image improvements in startup time and memory consumption with a demo app I wrote. The demo application converts images to PDFs. It’s available for Spring Boot 2 & 3, Quarkus, and Go. Check it out below.

Part 15 of 15 in the Talks series.
LJC Live Talk: "When Is Native Java With GraalVM Worthwhile for Me?" » | Start: LJC Lightning Talk: Eclipse OpenJ9: Memory Diet for Your JVM Applications

Java Tech Popularity Index Q1/2024:
Developer job ads down 32% year over year, Stack Overflow questions dropped 55% since ChatGPT. I now recommend IntelliJ Community Edition because many AI code assistants don't run in Eclipse. Job ads for Quarkus hit an all-time high.

Read my newsletter


comments powered by Disqus