How Java 9 will change your life
Java 9 was the culmination of years of development, updating this old favorite to the needs of the modern internet. But what do we mean by modern, anyways? In this article, Richard Gall explains why modern means refined, advanced, and convenient… and how Java 9 is all of these things.
This evolution may compromise Java’s claim of being simpler than C++, but my guess is that the effort will make Java a better language than it is today.
Over the last year or so, programming languages have regularly been prefixed with a curious word: modern. Modern Java. But what exactly does modern mean when used in this way?
When someone talks about modern languages, they’re really just talking about how refined, how advanced and how convenient a programming language is. This also means that the language is capable enough not just to solve problems of the present, but of the future as well. A long line of features like scalability, being cloud-ready, and supporting newer paradigms and architectures is expected of a “modern” programming language.
New features in Java 9
- The module system: Java’s new module system, hands down, is a game changer for sure! Based on Jigsaw, the much-awaited system will ensure strong encapsulation and better organisation of code.
- JShell: It’s about time Java got its own command line tool. This REPL enables you to run code without having to wrap it into classes. It’s a great tool especially for beginners to the language.
- Enhanced Stream API: We loved the Stream API when it debuted in Java 8 and guess what? It’s gotten better in Java 9! There are new methods added to the interface as well – iterate, takeWhile, dropWhile and ofNullable.
- Ahead of Time Compilation (AoT): This is a brand new feature and although still in an experimental phase, it enables improved startup time of applications via the compilation of Java classes into native code, before being launched in the VM.
- HTTP/2 client for Java 9: HTTP/2 is the future! Although not a complete rewrite of the previous version, HTTP/2 allows the server to send back more data than requested by the client. How cool is that?!
- Immutable Collections: Java 9’s Collection Factories will allow you to create immutable collections, thus saving you loads of time and code.
- Enhancements in the Process API: This will extend Java’s ability to interact with the OS. There are new direct methods to handle process states and names, and possessing the ability to enumerate JVMs and much more.
These and several other features will change the way you write code in Java and will surely ensure a delightful experience of programming in Java 9. In addition to the new features, some not-so-useful ones were deprecated as well, for the good. Some of them being the Applet API which isn’t as popular as it used to be, the AppletViewer and the CMS garbage collector have been shown the door too.
Be it for building Android applications, or for building a beautiful Cloud Native cum Serverless Web Application, or for that matter, to bring robustness and scalability to Data Science, Java is your answer. And then there’s Spring 5 – need we say more?
You should know though, that JDK 9 is just the end of the beginning. Oracle mentioned that future releases will be on a six-month cycle. Moreover, there won’t be a Java 10 and future releases will be named after the year and month in which they debut. For example, the next planned release will be in March 2018, hence Java 18.3. The release everyone has their eyes on (and you should too), is the September 2018 release or Java 18.9, which is the next long-term-release. For those of you who are still rolling on JDK 8, there’s good news – it will have extended support until 2025. The table below taken from the Oracle website will give you a better understanding.
All in all, there’s tremendous developments happening in Java SE and the community is working hard to keep the language the number one choice of developers. We recommend you let Java 9 rock your world; it’s time to discover new potential, do things like you could never do before and create life-changing applications of the future.
Packt are currently offering 75% off ‘Java 9 Cookbook’ by Mohamed Sanaulla and Nick Samoylov. Take advantage of the offer here.