Java 12 was released without much discussion. For such a mature language as Java, each update seems unable to satisfy the large Java development community and ecosystem. Add in Oracle’s intriguing attitude toward Java, and what does the future hold for Java?
Java has never changed faster — new versions of the language are now released every six months.
Such a significant shift was made possible by a series of collaborative projects focused on improving performance and adding new features. The goals are ambitious. As JetBrains developer evangelist Trisha Gee said at QCon London 2019, “There’s a lot of cool stuff coming out of Java.”
There are three major projects on the road that will help define the future direction of Java.
The Loom project
An attempt to improve concurrency in the Java language, or to explore the ability of computers to switch between different instruction sets.
Ron Pressler, technical lead of Oracle’s Loom project, presented two less-than-perfect options to Java developers looking to write software to handle concurrent tasks at QCon London 2019: Either write “simple synchronous blocking code” that cannot be extended to handle a large number of concurrent tasks, or write asynchronous code that is extensible but extremely difficult to write and difficult to debug.
Looking for a solution to this problem, Project Loom introduced a new method of breaking tasks into threads — the smallest possible unit of execution for a computer to execute an instruction. In this regard, Loom introduces a new lightweight user thread called Fibers.
“With Fibers,” he pointed out at the conference, “if we make sure it’s lighter than threads provided by the kernel, then the problem is solved. You’ll be able to use as many of these lightweight threads in user mode as you can with very little blocking.”
With these new fibers, users will be able to extend the Java Virtual Machine (JVM) to support delimited continuations, allowing the execution of instruction sets to be paused and resumed. The task of suspending and resuming these continuations is handled in asynchronous mode by the ForkJoinPool scheduler in Java.
According to the documentation, Fibers will use a very similar API to Java’s existing Thread class, which means the learning curve for Java developers shouldn’t be too steep.
Second, the Amber Project
The Amber project aims to support the development of “smaller, productivity-oriented Java language features” to speed the addition of new features to the Java language.
This solution is well suited to the new versions of Java that have been released at a faster pace since Java 9.
Currently, the following JDK enhancement proposal (JEP for short) is in the works as part of the Amber project.
Generating string:
https://openjdk.java.net/jeps/326Copy the code
Generative strings make it easier for developers to properly format text without the complexity of escaping characters.
For example, developers don’t have to use it
Escape characters to represent newlines, so in the following string:
Hello
WorldCopy the code
It can be written directly as:
`Hello
World`Copy the code
Instead of the original:
"Hello
World"Copy the code
The proposal’s documentation notes that this change will make it easier to input all kinds of text cameos, from file paths to SQL statements.
As you can see, raw strings should be enclosed in backquotes.
Intrinsic: Java compiler for JDK apis
https://openjdk.java.net/jeps/348Copy the code
This proposal will allow developers to optimize the performance of important pieces of code that need to be invoked on a regular basis.
Specifically, it allows developers to specify JDK-specific methods as compile-time internalization candidates, instructing the compiler to optimize their performance.
Given its importance in Java, the documentation for this proposal uses String:: Format and Objects:: Hash as examples of compile-time internalization methods. These methods can be annotated with the @intrinsiccandidate to instruct the compiler to treat them as compile-time internalization candidates. This way, the JDK’s Javac compiler can modify the processing mechanism that creates the internalized process.
The Pattern Matching:
https://openjdk.java.net/jeps/305Copy the code
Pattern Matching can simplify the process of using the Java instanceof operator to check if an object belongs to a particular class and then extract the object’s components for further processing.
In this case, the following operation syntax:
if (obj instanceof Integer) {
int intValue = ((Integer) obj).intValue();
// use intValue
}Copy the code
Can be simplified as:
if (x instanceof Integer i) {
// can use i here, of type Integer
}Copy the code
The Switch Expressions:
https://openjdk.java.net/jeps/325Copy the code
Switch Expressions is available in preview form in Java 12, allowing developers to specify different responses to input via Switch statements with simpler syntax.
For example, we no longer need to always use switch statements in the following syntax:
switch (port) {
case 20:
type = PortType.FTP;
break;
}Copy the code
More succinct expressions are as follows:
Switch (port) {
case 20 -> PortType.FTP;
}Copy the code
Valhalla Project
The Valhalla project focuses on the development of “advanced” JVM and language capabilities.
Currently, the Valhalla project has a limited number of candidate proposals, including:
Value Types:
https://openjdk.java.net/jeps/169Copy the code
This proposal aims to allow the JVM to handle a new type, Value Types.
These new immutable types will have the same memory efficiency as primitives such as Ints, but will be able to hold a whole set of primitives like normal classes. The proposal notes that the goal is to “provide the JVM infrastructure with the ability to handle immutable and referenceless objects to achieve the goal of efficient value-by-value calculations using non-primitive types.”
Generic Specialization:
https://openjdk.java.net/jeps/218Copy the code
This proposal extends the specific Types applicable to generics to include primitives and the forthcoming Value Types.
The original English
Future of the Java programming language: Three major projects on the horizon
Warning from Oracle
Java 8, the most widely used version of Java, was released in 2014, and Oracle officially supports Java 8 until December 2020, after which fixes to the Oracle JDK 8 will no longer be available for individual desktop users. After January 2019, free commercial updates will no longer be available, at which point a subscription will be required to continue to receive commercial support and maintenance from Oracle.
An Oracle sales representative sent out a much-discussed email stating that a “non-publicly available critical patch update for Java 8” would be released on April 16, 2019, and would be available to customers with valid licenses. The email went on to say that failing to install these updates could leave “your server and desktop environment exposed and vulnerable.”
But to many Java users, the email looked like an extortion or intimidation tactic.
Oracle dropped out and OpenJDK moved on
Although Oracle officially opted out of support, the Java community picked up the slack. Andrew Haley, lead engineer on Red Hat’s Java Platform team, has stated that Red Hat plans to continue providing support for OpenJDK 8 until 2023:
In my opinion, this is relatively normal. A few years ago, the OpenJDK 6 Update (JDK6U) project was abandoned by Oracle and I took it over, then the same thing happened with OpenJDK 7. Finally, Azul’s Andrew Brygin took over OpenJDK 6. The OpenJDK Vulnerability Group, made up of members from multiple organizations, collaborates on important security issues. With the help of the large OpenJDK community and my team (Red Hat), we provide regular updates for key bugs and security vulnerabilities. I think the same process applies to OpenJDK 8 and the next long-supported release, OpenJDK 11.
I would be happy to lead the JDK 8 update project and the JDK 11 update project if I could get community support.
In addition to Red Hat, AWS has launched Amazon Corretto, a long-term support version of the OpenJDK. Alibaba has also opened source a long-supported version of OpenJDK, Alibaba Dragonwell.
Is Java old enough to survive?
Is Java the best language? No, because there are better programming languages for every domain.
C is undoubtedly the king of modern computer software programming languages, and almost all operating systems are written in C. C++, the object-oriented C language, is constantly improving.
JavaScript is a language that can run in the browser, and the rich front-end interface is due to JavaScript. In recent years node.js has found its way back into the back end. Python is used for system administration and provides an API for scientific computing, text processing, and more through high-performance precompiled libraries. Python is the interpreted language of choice for Linux.
Ruby is stronger than DSL (domain specific language), and programmers can define rich semantics to fully express their ideas. Erlang is designed for distributed computing, ensuring robustness and stability in the face of large-scale concurrent access. Go has built-in concurrency capabilities to compile native code. At present, a large proportion of new network related projects are written in Go language, such as Docker, Kubernetes and so on.
Write web pages in PHP, do functional programming in Lisp, and write iOS applications in Swift/ObjectiveC.
In short, languages that stay on top of the charts are good languages that are the best at what they do.
So what is it about the Java language that makes it to the top of the list?
First, the syntax is relatively simple, and any developer who has learned computer programming can learn it quickly.
Secondly, it has strong competitiveness in several fields, such as server-side programming, high-performance network programs, enterprise software transaction processing, distributed computing, Android mobile terminal application development and so on.
The most important point is to meet the needs of engineering, we know that modern software is collaborative development, so the code maintainability, compile-time check, relatively efficient operation efficiency, cross-platform capabilities, rich IDE, testing, project management tools. Has made Java the preferred choice for enterprise software companies, and favored by many Internet companies.
There are no shortcomings, it is easy to find Java software engineers from the market, software companies choose Java as the main development language, and then use other languages in a specific field of collaborative programming, such a combination of choices, there is no big problem.
So overall, the Java language is the best in terms of versatility.
As Java updates every six months and new versions of Java introduce more and more features similar to those of other languages, Java will continue to be alive and well, do you think?