<div dir="ltr">Brian's article from yesterday walks through it all carefully. This message is my attempt at a summary.<div><br></div><div>When I step back I'm astounded that we've come this far: most developers, most of the time, will be able to reason like so:</div><div><br></div><div>"I give up things I don't need, then I let the VM do its thing, and my performance is better. If I care to learn the gory details, I can."</div><div><br></div><div>(Granted, the sort of developers reading *this* thread will want more than that, and in Brian's post they have it.)</div><div><br></div><div>But from *this* vantage point, here's where we're at today, as concisely as I can manage:</div><div><div><br></div><div>1. If your class doesn't do Identity Things, make it a value class. The VM can do smarter things now.<br><br>2. `==` isn't really an Identity Thing: it will just continue to mean "observably identical*" as it always has. System.hashCode() remains defined in terms of `==`. But actual identity dependence will fail (when feasible, at compile time).</div><div><br>3. Any type based on that class can be marked as nullable `?` or non-null `!`. Conceptually (if not literally), `Foo!` is a subtype of `Foo?`.</div><div><br></div><div>4. Nullness enforcement is "best-effort" and better than nothing. *If* you want the gory details of what's enforced you can dig into them. There's still room for third-party nullness analysis tools to help.<br></div><div><br><div>5. If a value class has a do-nothing constructor, and you're fine with non-null variables of that type being initialized to that value, add `implicit` to the constructor. The VM can do more smarter things now.<br></div><div><br></div>6. Consider adding `non-atomic` to the class; the VM can do even morer smarter things now. The downside is that racy code (already risky) might fail in worse ways; you decide if that worries you or not.<br><br>7. The above holds for the 8 primitive types too; yes, they are still special, but mostly in <i>additional</i> ways, rather than exceptions to the usual rules. `int` and `Integer!` are now nearly synonymous.<br><br>And we can finally all retire the term "primitive class" now at last. :-)<div><br></div><div>While that list is meant to have asterisks and just be "good enough for most people most of the time", it might need some important corrections nevertheless, so, I'm glad to hear them.</div><div><br></div><div><br></div><div>* yes float/double are weird</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="line-height:1.5em;padding-top:10px;margin-top:10px;color:rgb(85,85,85);font-family:sans-serif"><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Kevin Bourrillion |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Java/Kotlin Ecosystem Team |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(0,153,57);padding-top:2px;margin-top:2px"> Google, Inc. |</span><span style="border-width:2px 0px 0px;border-style:solid;border-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a href="mailto:kevinb@google.com" target="_blank">kevinb@google.com</a></span></div></div></div></div></div></div></div></div></div></div>