📜 ⬆️ ⬇️

JAVA 9. What's new?

Java is an amazingly universal programming language. Today, there are about 6.5 million Java developers around the world. And all thanks to its utility, ease of use, security and independence of the platform (it works regardless of what equipment or operating system is used).

Java was developed in 1995 by Sun Microsystems and was originally designed for interactive television and programming consumer electronic devices. Nevertheless, the public release of Java 1.0 revealed a shift in focus to Internet usage, turning it into one of the most popular programming languages.

Obviously, much has changed since 1.0, and finally, after a lot of hyphenation, on September 21, 2017, the release of Java 9 took place.
')
The features of the previous (8th) version, thanks to their versatility, provided developers with the opportunity to create solutions for various business sectors, including fintech, healthcare, and other industries. Among the key innovations of Java 8, lambda expressions, streams and changes in the API should be noted.

In turn, Java 9 also abounds in a variety of updates “under the hood” and in the API. In addition to the obvious Jigsaw project, which is responsible for introducing modularity into the core components of Java, the new version boasts three more important features:

  1. Full HTTP 2.0 client support: The issue is speed, and HTTP 2.0 provides better results, ranging from 11.81% to 47.7% compared to the HTTP 1.1 client.
  2. Jshell: New command line tool. If a developer wants to autonomously run multiple Java strings, this can be done without having to wrap everything in a separate method or project.
  3. Microbenchmark: Now the performance of individual small parts of the code can be measured by a standardized method. JMH analysis per nanosecond is unique to Java 9.



We advise you to familiarize yourself with the complete list on the Java community portal , as well as freely download the distribution kit for review.

Next, we take a closer look at several features that were missing in Java 8.

HTTP / 2 client

This is perhaps the most anticipated innovation - an HTTP client with support for both the HTTP / 2 protocol and WebSocket. After all, the SPDY protocol from Google, on the basis of which HTTP / 2 is based, already demonstrates improved performance along with Netty or Jetty, support for non-blocking mode (many threads for a request / response), and also Push support for the server, which allows sending resources to the client without an explicit request.

The new API is presented as the first incubator module for Java - an experimental feature that, with proper development, will officially appear in the next version (that is, Java 10), or will be removed. Unusual concept for Java, which encourages experimentation, but does not violate backward compatibility.

Jigsaw project

The Jigsaw project (translated as “puzzle”) aims to modularize Java. This means that the program code is divided into parts and organized into modules depending on the tasks that these modules perform. This allows you to reuse modules, simplifies their organization and debugging. Which leads to optimized and streamlined software development. This is the key difference between Java 9 and Java 8.

The second big advantage is that the Java Platform becomes lighter and more scalable. This allows Java-based applications to work even on devices with low productivity (as the work requires less resources). This is a big change especially in the context of the Internet of Things (IoT). A step forward for Java, and a chance to see more IoT applications written in this language.

Jshell

Jshell adds native support and popularizes the Java approach to the REPL (Read-Eval-Print-Loop). This is an interactive tool that allows you to test small parts of the code without having to create new classes. It is equipped with functions of history and autocomplete, as well as a number of other features, including the preservation and loading of written expressions.
For example, if you want to run a few lines of Java yourself, now you don’t have to wrap them in a separate project or method. As for the semicolons, you can forget about them: There are various alternatives like the REPL plug-ins for the popular IDE or the Java web console REPL, but none of them is official.

JVM Unified Logging

Added a single logging system for all JVM components. However, if we look at the pros and cons of Java 9, here is one of them. Logging calls for individual JVM components are missing, as well as Java code logging in the Java Development Kit

G1 - default garbage collector

Very often we are confused with the fact that there is only one garbage collector in Java, although there are 4 of them. Parallel / Throughput Collector was considered default in previous versions, but now it has been replaced by G1, which was introduced in Java 7 and was designed to better support heaps larger than 4GB. It causes less GC pauses, but if they do occur, it lasts longer.

Multi-resolution images

This API allows you to encapsulate a set of images with different resolutions in a single object. Thus, the developer can obtain an image with a specific resolution or all the options within one.

Notable API updates: Concurrency and Stack Walking

Java 9 received the update CompletableFuture and java.util.concurrent.Flow. Flow is a Java implementation of the Reactive Streams API. Reactive Streams help solve the problem of back-pressure - the accumulation of a large amount of data, which occurs when the speed of receiving incoming events is higher than the speed of processing them by the application, which leads to the appearance of raw data buffers. In addition, as part of the improved concurrency, CompletableFuture received an update that solved the problems identified after its implementation in Java 8. It includes support for delays and timeouts, improved support for subclasses and several useful methods.

I would also like to mention the Stack Walking API. That's right, Java 9 changes the approach to working with stack traces, providing an official way to handle stack traces, rather than equating them to plain text.

Immutable List, Set, Map, and Map.Entry API

Creating sets of multiple elements in Java 8 required several lines of code. Now this can be done only by one. Thus, one of the most time consuming drawbacks of Java 8 has been fixed. This should make it easier to work with arrays and speed up some functions.

Java 9 benefits

Details of the differences between Java 9 and Java 8 are of great interest for developers, and therefore for businesses in search of the best solutions. Innovations of the ninth version improve the following aspects of development:


THE END

Here is such a squeeze of all the interesting changes that we noted after the release of the new version. However, now the main question is when the companies will start to implement it, given that there are those who also do not use the eighth version. As a result, so far we have decided not to change the course program (not counting small cosmetics) and leave everything as it is, and next year to think about it.

Source: https://habr.com/ru/post/341058/


All Articles