<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Javascript puzzler: throw null</title>
	<atom:link href="http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/feed/" rel="self" type="application/rss+xml" />
	<link>http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/</link>
	<description>Mostly about the management of software development</description>
	<lastBuildDate>Thu, 10 May 2012 08:56:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Adam</title>
		<link>http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-240</link>
		<dc:creator><![CDATA[Adam]]></dc:creator>
		<pubDate>Mon, 15 Aug 2011 21:29:39 +0000</pubDate>
		<guid isPermaLink="false">http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-240</guid>
		<description><![CDATA[This particular case isn&#039;t actually an example of static typing helping you.

Null is a perfectly valid value for something of type Exception or Throwable to have in java, so from a typing point of view there&#039;s no reason that null exceptions couldn&#039;t be thrown around. What stops this from happening in Java is simply the special case you linked to in the JLS (and the fact that underneath, it&#039;s almost certainly doing something like expression.getClass().isAssignableFrom(Throwable.class) during the throw and expression.getClass() obviously throws a NullPointerException if expression is null).

It probably would make sense for Javascript to do something similar - throwing null is almost certainly a mistake, so when it happens automatically changing it to an Error(&quot;null thrown&quot;) might be better.]]></description>
		<content:encoded><![CDATA[<p>This particular case isn&#8217;t actually an example of static typing helping you.</p>
<p>Null is a perfectly valid value for something of type Exception or Throwable to have in java, so from a typing point of view there&#8217;s no reason that null exceptions couldn&#8217;t be thrown around. What stops this from happening in Java is simply the special case you linked to in the JLS (and the fact that underneath, it&#8217;s almost certainly doing something like expression.getClass().isAssignableFrom(Throwable.class) during the throw and expression.getClass() obviously throws a NullPointerException if expression is null).</p>
<p>It probably would make sense for Javascript to do something similar &#8211; throwing null is almost certainly a mistake, so when it happens automatically changing it to an Error(&#8220;null thrown&#8221;) might be better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nik</title>
		<link>http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-239</link>
		<dc:creator><![CDATA[Nik]]></dc:creator>
		<pubDate>Wed, 30 May 2007 20:05:11 +0000</pubDate>
		<guid isPermaLink="false">http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-239</guid>
		<description><![CDATA[aarondr, you&#039;re right that it&#039;s not good practice to use the thrown object to identify the fact of the exception, but that&#039;s much easier to say that after the event. The pain I experienced was due to someone else&#039;s very poor code which threw null. But it was allowed to throw null due to Javascript&#039;s typing being so loose its trousers are round its ankles.

Meanwhile, I&#039;m not sure about that particular argument in favour of loose typing. I wouldn&#039;t speak too ill of loose typing -- it certainly has its place. But just because a language doesn&#039;t trap compile-time errors it doesn&#039;t follow that it therefore helps you trap runtime errors.]]></description>
		<content:encoded><![CDATA[<p>aarondr, you&#8217;re right that it&#8217;s not good practice to use the thrown object to identify the fact of the exception, but that&#8217;s much easier to say that after the event. The pain I experienced was due to someone else&#8217;s very poor code which threw null. But it was allowed to throw null due to Javascript&#8217;s typing being so loose its trousers are round its ankles.</p>
<p>Meanwhile, I&#8217;m not sure about that particular argument in favour of loose typing. I wouldn&#8217;t speak too ill of loose typing &#8212; it certainly has its place. But just because a language doesn&#8217;t trap compile-time errors it doesn&#8217;t follow that it therefore helps you trap runtime errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aarondr</title>
		<link>http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-238</link>
		<dc:creator><![CDATA[aarondr]]></dc:creator>
		<pubDate>Wed, 30 May 2007 18:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-238</guid>
		<description><![CDATA[I know this is old, but I never really felt like using the object that is thrown is a good practice.  Honestly, you know if the catch block executes that there was a problem, so why not just say, 
problem_found = true;
One thing I have learned is to expect that &#039;null&#039; may exist where I don&#039;t expect, and if I don&#039;t have control over the object, then I certainly don&#039;t know what to expect out of it.

I prefer JavaScript over Java only to the fact that I have much more freedom of expression, and I am not having to keep strict types.  Strict typing only offers compile time safety and error checking, runtime errors are much more dangerous anyways.  I one respect, JavaScript lets you concentrate on removing the more important errors.  This instance I blame the interpreter, not the language.]]></description>
		<content:encoded><![CDATA[<p>I know this is old, but I never really felt like using the object that is thrown is a good practice.  Honestly, you know if the catch block executes that there was a problem, so why not just say,<br />
problem_found = true;<br />
One thing I have learned is to expect that &#8216;null&#8217; may exist where I don&#8217;t expect, and if I don&#8217;t have control over the object, then I certainly don&#8217;t know what to expect out of it.</p>
<p>I prefer JavaScript over Java only to the fact that I have much more freedom of expression, and I am not having to keep strict types.  Strict typing only offers compile time safety and error checking, runtime errors are much more dangerous anyways.  I one respect, JavaScript lets you concentrate on removing the more important errors.  This instance I blame the interpreter, not the language.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zproxy</title>
		<link>http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-237</link>
		<dc:creator><![CDATA[zproxy]]></dc:creator>
		<pubDate>Wed, 11 Apr 2007 07:42:53 +0000</pubDate>
		<guid isPermaLink="false">http://niksilver.com/2006/11/23/javascript-puzzler-throw-null/#comment-237</guid>
		<description><![CDATA[But you could compile statically typed language to javascript :)

visit http://jsc.sf.net]]></description>
		<content:encoded><![CDATA[<p>But you could compile statically typed language to javascript <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>visit <a href="http://jsc.sf.net" rel="nofollow">http://jsc.sf.net</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

