Beyond Java 8: The Cool Stuff
Java is evolving rapidly. Henri Tremblay is walking through the cool stuff. Henri is, besides other activities a contributor to EasyMock
From Java 7 (2011) to Java 19 (2022)
Unless stated otherwise Java 17 (2021) LTS will work for the examples. Henri used a trading app to walk through upgrading steps.
Impressive: just moving from Java 8 to Java 19 shows double digit performance improvements
Some of the tips:
- use the java.time.Clock object for anything date/time, Don't use
Date
. Inject the clock object. - use Comparators
- use Files.lines to read by line
- use the Maven deamon to speed compilation
- Be careful with
stream().findAny()
- in most cases aMap
performs way better - Use
"""
text blocks (why o why did Java not pick the tripple backtick) - Use
Files.writeString
if it is a String you write - Use jlink and jpackage for distribution
- Use switch expressions which returns values (not convinced about that yet)
- Use Records for immutable data
- Use the new instanceof syntax
- Use the new RandomGenerator for better performance
- Sealed types allow tighter controls
A quite enjoyable session
Posted by Stephan H Wissel on 20 October 2022 | Comments (0) | categories: Java Maven