What’s the Future of Java and Other Java Virtual Machine Languages?
Among the many innovations Java introduced was the exposure of its internal byte code, or “virtual machine.” Many languages by then (1995) were converted or compiled into some intermediate format before being assembled into native machine code, but Java’s designers placed this virtual machine at the center of the Java development process by distributing programs in that form—all in the cause of portability.
Figure 1 shows some Java code from the open source Kafka Streams project, displayed in the IntelliJ IDEA running on a Macintosh.
After the Java Virtual Machine (JVM) became nearly ubiquitous, other language developers thought of piggybacking on it, to gain instant portability. Furthermore, programmers using the new languages could bring legacy Java libraries into their programs. So now, the JVM probably supports the biggest collection of languages of any bytecode. Besides Java, one can enjoy the riches of Clojure, Groovy, Kotlin, and Scala. (This article doesn’t consider languages that weren’t designed for the JVM, but for which someone created compilers to create JVM output. These hybrid systems don’t get much use.)
Twenty-five years into the use of the JVM, how are the languages faring? How does the existence of each language affect the others?
To answer these questions, I talked to three colleagues who had authored books about these languages, and with whom I’d developed a relationship while editing their books at O’Reilly Media: Daniel Hinojosa, Zigurd Mednieks, and Blake Meike. Hinojosa is big Scala fan, Mednieks has migrated from Java mostly to Kotlin as part of the Android developer community, and Meike has explored several of the languages. Each has connections and roots in his community, and a valuable historical perspective.
Java Usage on the Cusp of a Change
The first point to understand is that Java is the whale that dominates this programming inlet. A survey of 2,000 practitioners in the second half of 2019, conducted by the snyk programming tools company, showed that Java accounts for 86.9% of the use of JVM-based languages (p. 17 of the PDF).
But will this continue? Meike points out that Oracle will soon start charging substantial fees for the Java Development Kit (JDK). Given Oracle’s trademark on Java, adds Mednieks, the developers and users of open source alternatives face an uncertain legal environment. For many large shops, the fees are no problem. But many students, free software developers, Internet-of-Things tinkerers, and others who drive upcoming generations of technology may choose other languages. Their choices might be the languages highlighted in this article, or others.
Businesses are conservative in their moves to new languages, as shown by the way COBOL continues to pop up in 2020, so we can feel assured that Java will be important for a long time. But gradually, we’ll see a shift away from Java in various parts of the programming ecosystem.
For instance, most projects sponsored by the Apache Foundation—including the historic Hadoop data crunching software and the Lucene search engine—have historically offered Java interfaces as their default APIs; this could well change. Already we are seeing Apache projects that feature Scala and Python APIs along with Java.
Cross-fertilization Among Languages
Also of interest is the way other JVM languages influence Java. Language developers are always checking out popular features offered elsewhere and incorporating them. Even C++ evolves this way. But proponents of JVM languages such as Kotlin and Clojure notice, in particular, that features in these languages (which often fall under the somewhat squishy term “functional programming”) turn up in later Java releases.
Does this represent progress? Hinojosa tells me that the new features aren’t used much by Java programmers. He has learned this through informal surveys, including a “State of Java” online chat he recently held that drew 300 participants. Part of the reason for the neglect of new features is a delay in upgrading to new versions of the JDK. However, almost everybody has upgraded at least to version 8 (see p. 12 of the snyk survey), which introduced most of the functional features of Java. So it seems like dyed-in-the-wool Java programmers are comfortable with how they’ve done things all along.
My colleagues tell me that Java libraries are easy to use in the other languages, but it’s not so easy to get a Kotlin or Scala library to work in a Java program. This is often because of different programming philosophies. For instance, Java setters are disparaged by Scala programmers, and the functional programming preference for immutable data often clashes with Java usage.
Some intriguing developments are taking place in some of the JVM languages.
Among the languages in this article, Clojure has the strictest adherence to functional programming style. Although its base is still fairly tiny, the language is gaining attention and adherents. Meike says developers are doing “cool things” with Clojure.
Google’s adoption of Kotlin as the language of choice for Android app development has naturally let it grab a toehold in current computing. Hinojosa says that the interest shown in Kotlin by the developers of the Spring framework helps too. The snyk survey shows that Kotlin has doubled its share of the market over the past year (page 17).
Because this article is nominally about the JVM, it should be pointed out that neither Java nor Kotlin ever used a JVM on Android. For performance reasons, they now run in a totally different environment, the Android Runtime (ART).
Meike finds that Kotlin is very similar to Swift, the language Apple designed for iOS development. He says this is very convenient for mobile developers, allowing them to recode their apps using familiar syntax.
This language has not been expanding in popularity as Clojure and Kotlin have. Meike thinks that Scala is on the way down. Compared to other current languages, he finds Scala too complex, and too hard to understand and maintain. Hinojosa adds that the Scala development community recently experienced a lot of contention, with postings seen as toxic by some developers and a controversy over the resulting institution of a code of conduct. However, Hinojosa believes that Scala is continuing to blossom and can pull itself out of a rut. My colleagues agree that these languages are converging, each offering the best features seen in the others.
In retrospect, Java was the crowning example of a generation of C-like programming languages. (Microsoft fans would say that C# was even better.) We are in a new age that favors other programming models, embodied in languages such as Clojure, Kotlin, and Scala. But the one common theme is a multiplicity of languages, which will keep programmers busy learning.