<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Imagine There&#8217;s No Null</title>
	<atom:link href="http://cafe.elharo.com/programming/imagine-theres-no-null/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/programming/imagine-theres-no-null/</link>
	<description>Longer than a blog; shorter than a book</description>
	<lastBuildDate>Tue, 09 Mar 2010 18:31:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Adelle DeWitt</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-455748</link>
		<dc:creator>Adelle DeWitt</dc:creator>
		<pubDate>Tue, 05 Jan 2010 18:40:27 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-455748</guid>
		<description>Elliotte: you really blew this one.  Nulls are great in safe languages like Java PRECISELY because they cause NullPointerExceptions.  (They are only bad in barbaric languages like C/C++ because they can corrupt memory.)

To see this, you need to realize that you are confusing symtoms with causes.  A NullPointerException is a symptom.  Failing to provide proper variable initialization is the cause.  Your proposal eliminates the symptom and allows the cause to go undetected.

But silent errors are the most insidious errors of all!  Failing to provide the right initialization of a variable, but letting the code proceed without crashing, is one such example.  It is much better to crash, since then you know that there is a problem.  You get that wonderful crashing behavior with Java objects, but not with primitives, which is unfortunate.

I see a contradiction between your calls for draconian error handling (which I heartily agree with) and your proposal here.

The only thing that Java needs reform of in default behavior is that there should be a convenient way to initialize primitive arrays.</description>
		<content:encoded><![CDATA[<p>Elliotte: you really blew this one.  Nulls are great in safe languages like Java PRECISELY because they cause NullPointerExceptions.  (They are only bad in barbaric languages like C/C++ because they can corrupt memory.)</p>
<p>To see this, you need to realize that you are confusing symtoms with causes.  A NullPointerException is a symptom.  Failing to provide proper variable initialization is the cause.  Your proposal eliminates the symptom and allows the cause to go undetected.</p>
<p>But silent errors are the most insidious errors of all!  Failing to provide the right initialization of a variable, but letting the code proceed without crashing, is one such example.  It is much better to crash, since then you know that there is a problem.  You get that wonderful crashing behavior with Java objects, but not with primitives, which is unfortunate.</p>
<p>I see a contradiction between your calls for draconian error handling (which I heartily agree with) and your proposal here.</p>
<p>The only thing that Java needs reform of in default behavior is that there should be a convenient way to initialize primitive arrays.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dstibbe</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-451048</link>
		<dc:creator>dstibbe</dc:creator>
		<pubDate>Fri, 11 Dec 2009 07:55:42 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-451048</guid>
		<description>First of all, I wasn&#039;t talking about users.
Second of all, there was nothing hypothetical about my example.

Perhaps you misunderstood because I used a String object as example? Take then, for example, a method that will create and return an object only under certain circumstances and otherwise null. If you still think that would be &#039;hypothetical&#039; I&#039;d have to wonder...

We agree that overloading is terrible. However, you have not given one reason to support that your &#039;seperate flag&#039; is better than (or any different from) a null value for an object. 

How would a flag indicating that an object was instantiated or not be any better or different than the null value that says the same thing?

- both need to be set
- both need to be checked</description>
		<content:encoded><![CDATA[<p>First of all, I wasn&#8217;t talking about users.<br />
Second of all, there was nothing hypothetical about my example.</p>
<p>Perhaps you misunderstood because I used a String object as example? Take then, for example, a method that will create and return an object only under certain circumstances and otherwise null. If you still think that would be &#8216;hypothetical&#8217; I&#8217;d have to wonder&#8230;</p>
<p>We agree that overloading is terrible. However, you have not given one reason to support that your &#8217;seperate flag&#8217; is better than (or any different from) a null value for an object. </p>
<p>How would a flag indicating that an object was instantiated or not be any better or different than the null value that says the same thing?</p>
<p>- both need to be set<br />
- both need to be checked</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C. Doley</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-449892</link>
		<dc:creator>C. Doley</dc:creator>
		<pubDate>Fri, 04 Dec 2009 21:43:50 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-449892</guid>
		<description>That&#039;s not a business case at all.  That&#039;s a hypothetical example that illustrates my point that programmers tend to make distinctions that have no bearing on the real world.  What you describe might not be a &quot;bug&quot; in the technical sense, but it sure sounds like a buggy business process to me.  How many of your users distinguish between &quot;not filling out a field&quot; and &quot;filling out a field with a blank value&quot;.  Answer:  0%

I concede that it may be possible to construct an example where there are multiple different states of a field not being filled in, for example if a user never saw it versus saw it and left it blank.  But I&#039;ll argue that trying to distinguish among these states by overloading a single field with values such as &quot;&quot;, &quot; &quot;, and null is a bad implementation choice.  Better to have a separate flag indicating the difference.</description>
		<content:encoded><![CDATA[<p>That&#8217;s not a business case at all.  That&#8217;s a hypothetical example that illustrates my point that programmers tend to make distinctions that have no bearing on the real world.  What you describe might not be a &#8220;bug&#8221; in the technical sense, but it sure sounds like a buggy business process to me.  How many of your users distinguish between &#8220;not filling out a field&#8221; and &#8220;filling out a field with a blank value&#8221;.  Answer:  0%</p>
<p>I concede that it may be possible to construct an example where there are multiple different states of a field not being filled in, for example if a user never saw it versus saw it and left it blank.  But I&#8217;ll argue that trying to distinguish among these states by overloading a single field with values such as &#8220;&#8221;, &#8221; &#8220;, and null is a bad implementation choice.  Better to have a separate flag indicating the difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dstibbe</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-437046</link>
		<dc:creator>dstibbe</dc:creator>
		<pubDate>Tue, 15 Sep 2009 12:50:21 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-437046</guid>
		<description>I do not agree. It does not give you any increase in possible values. There is still just an equal amount of strings possible.  Only difference is that in your case there is no NULL pointer but instead there is a boolean that tracks whether there should be a string or not (which is what the NULL pointer basically is). 


Regarding: 
&quot;Dozens of companies, hundreds of programs, and literally never in my life have I seen an application that differentiates between null and the empty string. &quot;
Simple case: Determine whether a string is given? If it is null, then it is not given, otherwise is it is, whether it is empty or not. 
Can&#039;t see what&#039;s buggy about that.</description>
		<content:encoded><![CDATA[<p>I do not agree. It does not give you any increase in possible values. There is still just an equal amount of strings possible.  Only difference is that in your case there is no NULL pointer but instead there is a boolean that tracks whether there should be a string or not (which is what the NULL pointer basically is). </p>
<p>Regarding:<br />
&#8220;Dozens of companies, hundreds of programs, and literally never in my life have I seen an application that differentiates between null and the empty string. &#8221;<br />
Simple case: Determine whether a string is given? If it is null, then it is not given, otherwise is it is, whether it is empty or not.<br />
Can&#8217;t see what&#8217;s buggy about that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C. Doley</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-428057</link>
		<dc:creator>C. Doley</dc:creator>
		<pubDate>Mon, 03 Aug 2009 14:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-428057</guid>
		<description>&lt;BLOCKQUOTE&gt;how is “non-nullable string + boolean” more flexible than a “nullable string + null!=string”?&lt;/BLOCKQUOTE&gt;

Simply because it has more possible values (i.e. num_possible_strings * 2 instead of num_possible_strings + 1).  Granted that&#039;s not necessarily super useful, but my point is that it&#039;s &lt;i&gt;at least as&lt;/i&gt; flexible.</description>
		<content:encoded><![CDATA[<blockquote><p>how is “non-nullable string + boolean” more flexible than a “nullable string + null!=string”?</p></blockquote>
<p>Simply because it has more possible values (i.e. num_possible_strings * 2 instead of num_possible_strings + 1).  Granted that&#8217;s not necessarily super useful, but my point is that it&#8217;s <i>at least as</i> flexible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toby</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-426722</link>
		<dc:creator>Toby</dc:creator>
		<pubDate>Thu, 30 Jul 2009 01:31:45 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-426722</guid>
		<description>&lt;blockquote&gt;&quot;it could dramatically increase program robustness by eliminating an entire class of common errors.&quot;&lt;/blockquote&gt;

Or rather, &quot;could dramatically DECREASE program robustness by HIDING an entire class of common errors.&quot;</description>
		<content:encoded><![CDATA[<blockquote><p>&#8220;it could dramatically increase program robustness by eliminating an entire class of common errors.&#8221;</p></blockquote>
<p>Or rather, &#8220;could dramatically DECREASE program robustness by HIDING an entire class of common errors.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dstibbe</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-419510</link>
		<dc:creator>dstibbe</dc:creator>
		<pubDate>Fri, 10 Jul 2009 08:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-419510</guid>
		<description>&quot;Having a non-nullable string + a boolean is even more flexible than a nullable string, and MUCH less error-prone.&quot;


how is &quot;non-nullable string + boolean&quot; more flexible than a &quot;nullable string + null!=string&quot;?</description>
		<content:encoded><![CDATA[<p>&#8220;Having a non-nullable string + a boolean is even more flexible than a nullable string, and MUCH less error-prone.&#8221;</p>
<p>how is &#8220;non-nullable string + boolean&#8221; more flexible than a &#8220;nullable string + null!=string&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C. Doley</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-418627</link>
		<dc:creator>C. Doley</dc:creator>
		<pubDate>Tue, 07 Jul 2009 16:23:44 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-418627</guid>
		<description>&lt;b&gt;@James:&lt;/b&gt; &quot;What about when you want to differentiate between the empty string and no string whatsoever? That’s why null exists.&quot;

The point is, in my 15+ years of programming, I have not once seen a case where such logic was necessary.  Dozens of companies, hundreds of programs, and literally &lt;i&gt;never in my life&lt;/i&gt; have I seen an application that differentiates between null and the empty string.  (More precisely, I&#039;ve seen hundreds of places where this is done, but in every case it has been a bug.)

As programmers we get too used to thinking about things in technical terms that have no meaning in the real world.  Ask any non-programmer when they want a piece of data to be empty and when they want it to be null and you&#039;ll get a blank stare.  There is just no need for this distinction.

We tend to get bogged down in false notions of flexibility.  For example, &quot;since having null strings allows me more flexibility than not having it, we should keep it.&quot;  But this is misleading and pointless.  Having a non-nullable string + a boolean is even more flexible than a nullable string, and MUCH less error-prone.</description>
		<content:encoded><![CDATA[<p><b>@James:</b> &#8220;What about when you want to differentiate between the empty string and no string whatsoever? That’s why null exists.&#8221;</p>
<p>The point is, in my 15+ years of programming, I have not once seen a case where such logic was necessary.  Dozens of companies, hundreds of programs, and literally <i>never in my life</i> have I seen an application that differentiates between null and the empty string.  (More precisely, I&#8217;ve seen hundreds of places where this is done, but in every case it has been a bug.)</p>
<p>As programmers we get too used to thinking about things in technical terms that have no meaning in the real world.  Ask any non-programmer when they want a piece of data to be empty and when they want it to be null and you&#8217;ll get a blank stare.  There is just no need for this distinction.</p>
<p>We tend to get bogged down in false notions of flexibility.  For example, &#8220;since having null strings allows me more flexibility than not having it, we should keep it.&#8221;  But this is misleading and pointless.  Having a non-nullable string + a boolean is even more flexible than a nullable string, and MUCH less error-prone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamlet D'Arcy</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-407345</link>
		<dc:creator>Hamlet D'Arcy</dc:creator>
		<pubDate>Tue, 09 Jun 2009 12:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-407345</guid>
		<description>As a user of a language with an Option type, I can say that it is a wonderful way to eliminate null from the language. The fact that Scala allows you to cast an Option type into an instance of a Some type should not be held against Option types in general. This is a problem with Scala&#039;s implementation and not the Option type idea. AFAIK, F# does not allow you to do this so I assume OCaml doesn&#039;t either. 

Having played with the JSR308 prototype (which includes the @NotNull/@Nullable annotations), I can say that I am deeply impressed with the work done by that group and excited to start using the annotations. It makes this discussion moot: If you don&#039;t want nulls then don&#039;t use them. And the 308 type checkers will make sure nobody does!</description>
		<content:encoded><![CDATA[<p>As a user of a language with an Option type, I can say that it is a wonderful way to eliminate null from the language. The fact that Scala allows you to cast an Option type into an instance of a Some type should not be held against Option types in general. This is a problem with Scala&#8217;s implementation and not the Option type idea. AFAIK, F# does not allow you to do this so I assume OCaml doesn&#8217;t either. </p>
<p>Having played with the JSR308 prototype (which includes the @NotNull/@Nullable annotations), I can say that I am deeply impressed with the work done by that group and excited to start using the annotations. It makes this discussion moot: If you don&#8217;t want nulls then don&#8217;t use them. And the 308 type checkers will make sure nobody does!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asbjørn Ulsberg</title>
		<link>http://cafe.elharo.com/programming/imagine-theres-no-null/comment-page-1/#comment-406905</link>
		<dc:creator>Asbjørn Ulsberg</dc:creator>
		<pubDate>Mon, 08 Jun 2009 12:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=401#comment-406905</guid>
		<description>While I agree NullPointerExceptions are annoying (in any language), I don&#039;t think replacing one default value (null) with another (e.g. empty string). Not because another default would make it simpler to program (it would!), but it would also lead to another set of (perhaps much harder to discover) problems.

The underlying problem with NullPointerException isn&#039;t that the variable ought to have a differet default value that we can use, but that the variable probably isn&#039;t initialized due to a bug. Our code expects the variable to have a value; that&#039;s why NullPointerException is thrown in the first place. If null is replaced by &quot;&quot; or whatever sensible default given the type we&#039;re operating on, it might open up a whole can of worms.

As you write yourself, you need to check for equality to &quot;default&quot; -- how&#039;s that really different to checking equality to &quot;null&quot;? When that &quot;if&quot; statement is required either way, I think it&#039;s better for the code to help you and throw a NullPointerException when you forget than just silently executing code that doesn&#039;t do what it should.</description>
		<content:encoded><![CDATA[<p>While I agree NullPointerExceptions are annoying (in any language), I don&#8217;t think replacing one default value (null) with another (e.g. empty string). Not because another default would make it simpler to program (it would!), but it would also lead to another set of (perhaps much harder to discover) problems.</p>
<p>The underlying problem with NullPointerException isn&#8217;t that the variable ought to have a differet default value that we can use, but that the variable probably isn&#8217;t initialized due to a bug. Our code expects the variable to have a value; that&#8217;s why NullPointerException is thrown in the first place. If null is replaced by &#8220;&#8221; or whatever sensible default given the type we&#8217;re operating on, it might open up a whole can of worms.</p>
<p>As you write yourself, you need to check for equality to &#8220;default&#8221; &#8212; how&#8217;s that really different to checking equality to &#8220;null&#8221;? When that &#8220;if&#8221; statement is required either way, I think it&#8217;s better for the code to help you and throw a NullPointerException when you forget than just silently executing code that doesn&#8217;t do what it should.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
