#21 Serializable Records
Fantastic JVMs and Where to Find Them. Double your performance: virtual threads. The proper care and feeding of your Gradle build. Real Software Engineering.
Welcome to the twenty-first edition of the Dukesletter!
Simple things should be simple, complex things should be possible.”
― Alan Kay
In any case, please wear a face mask.
Serializable Records
Records were released in JDK 14 and the next version will continue as a preview feature.
The learn about it I recommend to revisit this article from Brian Goetz: “Java 14 Feature Spotlight: Records”.
Records can look like syntactic sugar, and may seem to do the same thing as @Value annotation from Lombok: generate private final immutable fields with a single constructor, toString, equals, and hashcode methods.
But Records have some hidden gems: fix Java Serialization. Serialization implementation has been one of the biggest Java mistakes and has been a continuous source of security breaches. Because of the legacy code, Java cannot deprecate it.
Java Team can not solve the problem but can give us tools to avoid it: Records.
In “Serializable Records”, Chris Hegarty and Alex Buckley, explain how Serialization works for Records and how its characteristics prevent problems.
Usually, we need to serialize information that will be transmitted or persisted in binary format, and we use DTOs, a perfect match with new Records.
Fantastic JVMs and Where to Find Them
Is Java still free? Which JVM distribution can I use? Where can I find them?
Marcus Hirt has written an article with a summary of existing options, available versions, and where to find them: “Fantastic JVMs and Where to Find Them”.
I personally use JDK 11 from AdoptOpenJDK. In my local environment, I download and install them using SDKMAN, and in production, we use base images from the official AdoptOpenJDK Docker Hub account.
But if you have doubts about the Java license and think that someday Oracle will change its license, you can be sure, Java is in good hands.
To solve these doubts I recommend you read this article created by the Java Champions community (more than 40 independent Java leaders and experts) explaining every detail about distributions and how to avoid paying licenses to Oracle if you don’t need it: “Java is Still Free” (you can find the latest version in this Google Docs).
Double your performance: virtual threads (fibers) and JDK 15/16!
Probably this title is Clickbait, but it is interesting to see how new JDK releases allow us to improve the performance of our applications.
In “Double your performance: virtual threads (fibers) and JDK 15/16!“, Bela Ban from JGroups team, explains how moving to JDK 15/16 the performance of the library is boosted.
But the main reason is that some implementation changes in the network library improves the communication speed, and joined to the use of new virtual threads, he gets a 97% of throughput improvement.
This is a clear case where you can benefit from technology changes without changing your code, thanks to the stability offered by the Java platform.
The proper care and feeding of your Gradle build
In Gradle, when you have a multimodule project that depends on other multimodule project, and both have dependencies on a complex tool like SpringBoot using its dependency management plugin: you have a problem.
Do I have any unused dependencies in my build? Am I declaring my dependencies correctly? (api, implementation, compileOnly...) Am I using transitive dependencies that might be best declared directly? Why is overwriting this library version?
To answer these and more questions, Tony Robalik has created a Dependency Analysis Gradle Plugin. In “The proper care and feeding of your Gradle build”, the author explains its features and how to use it.
I haven't used it yet, but it looks promising and I'm looking forward to finding a free moment to put it into practice at work because we are suffering from it.
Real Software Engineering
Can the Software Development be considered as an Engineering? What is an Engineering? Glenn Vanderburg, with 45 years of experience developing software, reviews the history of the discipline and gives his opinion about this controversial issue:
Anybody with enough interest can learn to code. Which practices makes a software developer an Engineer?