Book review: Supercharge Your Applications with GraalVM

January 21, 2022 | 4 minute read
Text Size 100%:

An IBM Distinguished Engineer writes about the GraalVM high-performance Java Virtual Machine.

Download a PDF of this article

Supercharge Your Applications with GraalVM
     Supercharge Your Applications with GraalVM
     By A B Vijay Kumar
     360 pages
 

A professional reviewer’s motivation should always be the reader’s benefit. With this prime value in mind, it’s tempting to review only good books, as it’s far more valuable for a reader to know which books to buy than which ones to avoid. If Sturgeon’s Law, which states that 90% of everything is crud, is to be believed (and it should, in my opinion), there will always be nine times as many technology books to avoid than there are to read.

Fortunately, the technical book market for programmers is self-arranging, and it’s easy to know who offers the 10% that Sturgeon’s Law prefers. For example, Addison-Wesley, Manning, No Starch Press, O’Reilly, Pearson, and Pragmatic Programmers regularly put out excellent books, and titles from them have regularly appeared in my reviews. 

But the question persists: Why would a reviewer ever cover a poor book? There are several reasons, including

  • The book comes from a well-known author and readers would have expected a better work.
  • The book is written by someone with impressive credentials who didn’t live up to their billing (the case here).
  • The book is among the first to roll off the press on an important topic to a wide community (also the case here).

As you’ll shortly see, I cannot recommend the book being reviewed, so why review it? Primarily because it’s one of the first books on GraalVM, which is an interesting and important technology to the Java developer community. Also, the author is an IBM Distinguished Engineer, which suggests that this might be a technically solid volume with carefully written, informative content. I incorrectly had this expectation.

The book

This volume aims to present GraalVM as well as the ecosystem built up around it. Given the paucity of information about GraalVM, this should be a welcome overview and explanation of how to use the technology effectively.

The book starts with an ill-advised exploration of the non-Graal Java Virtual Machine—that is, the HotSpot JVM that all Java developers are familiar with. The “ill-advised” aspect is that the explanation is full of conspicuous errors. For example, it incorrectly states that the JVM’s interpreter turns bytecode into machine code. And later it states that to determine the classpath, the JVM must read the CLASSPATH environment variable.

Throughout the book, terminology is used incorrectly or simply invented (Java class files must obey “schematics,” the author explains) so it’s impossible to follow along unless you already know what the book is trying to teach you. A recap of the JVM chapter in the appendix creates further confusion by adding new errors to the material it summarizes.

The rest of the book focuses on GraalVM and here the quality improves somewhat. The descriptions appear to be more accurate and the various technologies—GraalVM itself, native images, the Truffle Suite framework, and LLVM—are explained intelligibly. The author explores extensively the kinds of optimizations performed by GraalVM. But the presentations are hampered by the author’s tendency to explain simple things in detail and shift to generalities when explaining more-complex topics.

Beyond this, I was greatly frustrated by the author’s persistent lack of rigor, even in basic matters. For example, there is a short section on using GraalVM with WebAssembly (Wasm). In the four pages this section comprises, the author provides a short program, explains how to run it with GraalVM’s Wasm capability, and presents a summary of the results.

The program is the prototypical Fibonacci computation performed for values of 10,000 to 10,010, and the timings of 10 runs are presented in a table. The first thing that caught my eye was the Fibonacci code. For the first time that I can recall in print, I spotted a for loop that uses the variable i but not as the iterating variable. I discovered this only after staring at the code and wondering how it could possibly work, assuming—as every programmer would—that i was used in its universal role.

Moving on to the table of timings from the 10 runs, the author makes this curious remark: “We can see a huge improvement from 6519ms to 247ms.” The timings, in fact, are not milliseconds, but rather microseconds. Also, the number 6,519 is oddly chosen: It’s neither the first number in the table nor the highest. If you pause to wonder why the author selected this particular midrange value to illustrate his point, you’re adding to the time lost figuring out the bizarre code. It’s all sloppiness.

Even if you move past all these problems, you might now expect some explanation for the great reduction in run times that he has brought to your attention. But there is none. In fact, the quoted sentence is the last one in the section covering Wasm.

Conclusion

The need for the reader to constantly fix—on the fly—the carelessness of the author and the technical reviewers to arrive at a dead end with no explanation pervades this book. On that basis, I cannot recommend this book at all. For information on GraalVM, you’re far better off consulting the project documentation, blog posts by developers connected with the project, and, of course, articles in Java Magazine.

Dig deeper

Andrew Binstock

Andrew Binstock (@platypusguy) is the lead developer on the Jacobin JVM project—a JVM written entirely in Go. He was formerly the editor in chief of Java Magazine, and before that he was the editor of Dr. Dobb’s Journal. Earlier, he cofounded the company behind the open source iText PDF library. He lives in Northern California with his wife, and when he’s not coding, he studies piano.


Previous Post

Quiz yourself: Java abstract classes and access modifiers for abstract methods

Mikalai Zaikin | 3 min read

Next Post


Curly Braces #1: Java and a project monorepo

Eric J. Bruno | 10 min read