<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Nov 19, 2024, at 6:22 AM, Anderson Vasconcelos Pires <<a href="mailto:andvasp@gmail.com" class="">andvasp@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class=""><font size="4" class="">Hi Guys!</font></div>
<div class=""><br class="">
</div>
<div class=""><span style="font-family:monospace;font-size:large" class="">So, we get that adding null restriction to Java will significantly worsen the fact that "nullable" is yet another bad default; this is pretty clear.</span></div>
<div class=""><span style="font-family:monospace;font-size:large" class=""><br class="">
</span></div>
<div class="">
<div class=""><br class="gmail-Apple-interchange-newline">
<font size="4" class="">About "nullable" being a bad default. Have you thought for value classes the default to be not nullable?</font></div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
Indeed we have. In fact, this was our initial position for a number of years, until we realized (thanks Kevin!) that this was a bad idea. </div>
<div><br class="">
</div>
<div>Asymmetries like this (value classes are non-nullable, identity classes are nullable) adds significant cognitive load to _reading_ code; users have to carry around a mental dictionary of what classes are nullable and what are not in order to be able to
reason about nullity. And further, asymmetries like this make it far more difficult to make migrating an identity class (like Optional) to be a value class. In fact, much of the complexity of our intermediate designs revolved around undoing the effects of
this “split default” choice. </div>
<div><br class="">
</div>
<div>
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class=""><span style="font-size: large;" class="">If we think in the long future to "fix" the default to be not nullable, this would be a step.</span></div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Half steps often look like steps, but looks can be deceiving. Getting halfway there by having a remote, (seemingly, to some users) random criteria determine whether a variable is nullable or not would not feel like a step to many.</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class=""><font size="4" class="">Thinking about reading code, maybe it is not a good choice to have this difference between value and identity objects because we would have to check the variable type to understand the logic.<br class="">
</font></div>
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
Exactly. (Among other reasons.)</div>
<br class="">
</body>
</html>