Java 14 makes code super expressive, say top developers.

Java 14 makes code super expressive, say top developers.

Java 14

What do developers love most about Java? For many, it’s how it manages to be so reliable (think Toyota) while still able to handle everything from parallel graph analytics to bleeding-edge finance (think Maserati).

With Java running critical applications the world over, the nearly 25-year-old programming language must constantly balance its community’s affection for its syntax with the latest trends. The release of Java 14 in March brings 16 main enhancements that span everything from more readable code to foreign memory access.

35,993 views|Apr 2, 2020,08:00am EDT
Java 14 Makes Code Super Expressive, Say Top Developers
Alexa Weber MoralesBrand Contributor
OracleBRANDVOICE| Paid Program
What do developers love most about Java? For many, it’s how it manages to be so reliable (think Toyota) while still able to handle everything from parallel graph analytics to bleeding-edge finance (think Maserati).

Java 14
ORACLE

With Java running critical applications the world over, the nearly 25-year-old programming language must constantly balance its community’s affection for its syntax with the latest trends. The release of Java 14 in March brings 16 main enhancements that span everything from more readable code to foreign memory access.

Download Java 14
Here’s what several Java Champions like best about the newest enhancements, which include some experimental and preview features.

Becoming More Expressive

“I am one of those folks who constantly complained that Java is verbose,” says Venkat Subramaniam, award-winning author and founder of Agile Developer. While code editing tools (IDEs) ease that burden by automatically crafting some statements in source code, he says, these can produce what developers disparagingly call “code vomits.”

That’s why there’s been a continual push, via the every-six-months release cycle, to streamline the language, removing excess verbiage and deprecating obsolete features. “Java 14 removes so much noise in code,” Subramaniam says, pointing to RecordsPattern Matching, and Switch Expressions. (Switch Expressions was first previewed in JDK 12). “These features remove boilerplate code and make code highly expressive, and intuitive—easy to both write and maintain.”

Records is a preview feature in Java 14. It lets developers declare data-related classes, with the ultimate goal (when the Java team collects feedback on the current preview from developers) of modeling data as data. According to New York City-based developer Jeanne Boyarsky, author of Sybex’s wildly popular Java 11 Oracle Certified Professional certification books, that means “less dealing with hashCode/equals and less for the code coverage [testing] tool to be angry at me about!”

Boyarsky is a fan of such moves to improve code readability and productivity, sharing that she’s also happy about Text Blocks, another preview feature. “They make it so much easier to write tests,” she says. “Putting a large string [of text] in your code without worrying about formatting is something I’ve long wanted in Java.”

What’s My App Doing?

With Java being a massive open source project in its own right, it sometimes overshadows the many open source tools in its orbit. Java Flight Recorder (JFR) first became available as open source in 2018 as part of OpenJDK 11. Now, Java 14 adds to JFR’s powerful insights with Event Streaming, which can reveal problems in memory allocation and how they affect performance.

“This is a great idea and approach to gathering metrics of a running application without the application experiencing observe effects,” says London-based Java Champion Mani Sarkar, who is eager to explore this feature further. Another nifty tool for finding bugs—specifically, when a program fails because no particular spot in memory was assigned to a variable—in Java 14 is Helpful NullPointerExceptions. “This feature is certainly helpful to developers,” Sarkar says. “For ages, we have had to do a bit of a search and sometimes it’s not obvious when an app fails due to an NPE.”

In today’s data-driven world, applications use terabytes of memory where they once used hundreds of megabytes. So the continued emphasis with each new release of Java on better performance and garbage collection (release of memory after it has served its purpose) makes a lot of sense. The new memory- and performance-related improvements in Java 14 include NUMA-Aware Memory Allocation for G1 garbage collector, Non-Volatile Mapped Byte Buffers, and Foreign-Memory Access API. This last feature helps make accessing additional types of memory for data-intensive programs safer.

What’s in the Incubator?

Now that the six-month release cadence is becoming second nature to the Java team, they’re able to deliver innovations faster as well, using incubator modules to give developers a peek at changes before they’re fully released.

“Making certain features available as a preview or incubator features is pretty handy,” says Sarkar, allowing developers “to play with them before adopting them into the language—or not including them if they weren’t viable or didn’t get good feedback.”

Subramaniam wholeheartedly agrees: “These features are paving the way for so many more improvements in future releases of Java.”

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest