#18 Optional
How we got the generics we have. Coherence Community Edition released. JDK Statistics. OAuth - Open Authorization
Welcome to the eighteenth Dukesletter edition!
The more you know, the more you realize you know nothing.
— Socrates
This Dukesletter edition is published in memorial of Bill Shannon. Even though he was Sun Microsystem's 11th employee, I didn't know much about him until last week. If you want to know who was Bill Shannon and his contributions to technology, you can read the following articles:
By David Rosenthal: Bill Shannon RIP
By Reza Rahman: A Tribute to Bill Shannon – A Giant of the Java Ecosystem
By Tim Bray: Quarter-Century Story
Recipes for using the Optional class as it’s meant to be used
Null Pointer References is the One Billion Dollar mistake, and to avoid it in Java we have the class Optional.
Optional was introduced in Java 8 and its API has been improved in the following releases, but many of us are not familiar with it or don't use it properly.
To improve our Optional usage, making our code more readable and concise, Mohamed Taman has written an article in the Oracle Java blog: “12 recipes for using the Optional class as it’s meant to be used”.
But I prefer this presentation from Mohamed, with more recipes and examples: “Do you use the Optional class as it should be?”
If you want to learn more about Optional, I propose to continue with this talk by Stuart Marks:
Historically, many people have complained that Optional was not serializable, and Stuart explains the reasons in the minute 46:41.
How we got the generics we have
Project Valhalla continues evolving and exploring how to improve Java Language and platform. For example one of the subprojects is the JEP 218 Generics over Primitive Types.
In these exploration process, Brian Goetz has analyzed why Java Generics were created the way they are, and which circumstances determined the type erasure.
He has written a very interesting article about the history of Java Generics: Background: how we got the generics we have (Or, how I learned to stop worrying and love erasure).
At the same time, Go Lang team has advanced in their proposal to include generics in Go: The Next Step for Generics. Probably it is the most demanded feature in Go since its creation.
Are they going to do the same mistakes, and take the same tradeoffs in their decisions? I hope they do better than Java in their day.
Coherence Community Edition released
When you have to manage a lot of information, and you need to access it quickly but doesn’t fit in memory in one server, you can distribute it between different servers, but you need to implement some special code to communicate all available servers.
Some libraries implement these mechanisms transparently for you, presenting the information as a big Map<Key, Value>. Values distribution, communications, and redundancy are managed by the utility.
Some of these libraries are: Hazelcast, Infinispan, EHCache/Terracotta, or Coherence from Oracle. Most of them are open-source except Coherence, until last week.
Last week Oracle announced that has published a Community Edition of Coherence under an Open Source License. Their main features are:
Clustering and Data Sharding
Disk-Based Persistence
Key-Value Data Store
Parallel Queries
Aggregations
In-Place Processing
The latest three features are very interesting if you need to execute queries beyond the key/value Map basic idea. You can learn more about these concepts on their web site.
My main concern about Data Grid technology is that it is based on some kind of Java Serialization, and I have not seen an implementation that solves data schema changes easily. What happens when you execute a rolling deploy and at the same time you have two different versions of the same class, with different attributes?
JDK Statistics
Not all JDK JEPs are technicals, and some of them are about how JDK is developed. JEP 369 has as objective to migrate all OpenJDK repositories to GitHub in the JDK 16 release.
But in the meantime, the JDK team is mirroring current JDK repositories in GitHub and we can explore its statistics using the GitHub Insights option.
We can discover that the project has had more activity than ever:
and the percentages of each language that make up the JDK: