Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Java Lambdas

You're reading from   Learning Java Lambdas An in-depth look at one of the most important features of modern Java

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher
ISBN-13 9781787282087
Length 114 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Toby Weston Toby Weston
Author Profile Icon Toby Weston
Toby Weston
Arrow right icon
View More author details
Toc

The road to modern Java

Java 8 was released on March 18, 2014, two years seven months after the previous release. It was plagued with delays and technical problems but when it finally came, it represented one of the biggest shifts in Java since Java 5.

The headliners were of course lambdas and a retrofit to support functional programming ideas. With languages such as Scala taking center stage and the modern trend towards functional programming, Java had to do something to keep up.

Although Java is not and never will be a pure functional programming language, the changes in Java 8 enabled developers to use functional idioms more easily than in previous versions. With discipline and experience, you can now get a lot of the benefits of functional programming without resorting to third-party libraries.

Modern Java features

To give you an idea of just how big a change Java 8 was, and why it ushered in a new, modern Java, here's a mostly complete list of the new features it introduced:

  • Lambda support.
  • The core APIs were updated to take advantage of lambdas, including the collection APIs and a new functional package to help build functional constructs.
  • Entirely new APIs were developed that use lambdas, things like the stream API which brought functional style processing of data. For example, functions like map and flatMap from the stream API enable a declarative way to process lists and move away from external iteration to internal iteration. This in turn allows the library vendors to worry about the details and optimize processing however they like. For example, Java now comes with a parallel way to process streams without bothering the developer with the details.
  • Minor changes to the core APIs; new helper methods were introduced for strings, collections, comparators, numbers and maths.
  • Some of the additions are changing the way that people code. For example, the Optional class will be familiar to some, and it enables a better way to deal with nulls.
  • There were various concurrency library improvements. Things like an improved concurrent hash map, completable futures, thread safe accumulators, an improved read write lock (called a StampedLock), an implementation of a work stealing thread pool and much more besides.
  • Support for adding static methods to interfaces.
  • Default methods (otherwise known as virtual extension or defender methods).
  • Type inference was improved and new constructs like functional interfaces and method references were introduced to better support lambdas.
  • An improved date and time API was introduced (similar to the popular Joda-time library).
  • The IO and NIO packages received welcome additions to enable working with IO streams using the new streams API.
  • Reflection and annotations were improved.
  • An entirely new JavaScript engine shipped with Java 8. Nashorn replaced Rhino, and was faster and had better support for ECMA-Script.
  • JVM improvements; the integration with JRocket was completed, creating a faster JVM.
  • The JVM dropped the idea of perm gen, instead using native OS memory for class metadata. This is a huge deal and provides better memory utilization.
  • The JRocket integration also brought Mission control (jmc) to the JDK as standard. It compliments JConsole and VisualVM with similar functionality but adds very inexpensive profiling.
  • Other miscellaneous improvements, like improvements to JavaFX, base64 encoding support and more.
You have been reading a chapter from
Learning Java Lambdas
Published in: Mar 2017
Publisher:
ISBN-13: 9781787282087
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image