<?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"
	>
<channel>
	<title>Comments on: How strict is your dynamic language?</title>
	<atom:link href="http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<pubDate>Thu, 04 Dec 2008 03:08:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: stu</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-68865</link>
		<dc:creator>stu</dc:creator>
		<pubDate>Tue, 17 Oct 2006 18:47:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-68865</guid>
		<description>comming late to the party ;) here is lua 5.1 example

&lt;code&gt;names = {
			{ first = "Bob", given = "Smith"},
			{ given = "Lukas"},
			{ first = "Mary", given ="Doe"},
		};

function printName(name)
	print("Name is " .. name.first .. " " .. name.given)
end

for x,y in pairs(names) do
	printName(y)
end&lt;/code&gt;

and the runtime output

&lt;code&gt;C:\lua\5.1&#62;lua5.1.exe x.lua
Name is Bob Smith
lua5.1.exe: x.lua:9: attempt to concatenate field 'first' (a nil value)
stack traceback:
        x.lua:9: in function 'printName'
        x.lua:13: in main chunk
        [C]: ?&lt;/code&gt;

Lua unfortunatly (imo) likes to co-erce things into strings and numbers when it can without explicitly being told to do so.</description>
		<content:encoded><![CDATA[<p>comming late to the party ;) here is lua 5.1 example</p>
<code>names = {
			{ first = "Bob", given = "Smith"},
			{ given = "Lukas"},
			{ first = "Mary", given ="Doe"},
		};

function printName(name)
	print("Name is " .. name.first .. " " .. name.given)
end

for x,y in pairs(names) do
	printName(y)
end</code>
<p>and the runtime output</p>
<code>C:\lua\5.1&gt;lua5.1.exe x.lua
Name is Bob Smith
lua5.1.exe: x.lua:9: attempt to concatenate field 'first' (a nil value)
stack traceback:
        x.lua:9: in function 'printName'
        x.lua:13: in main chunk
        [C]: ?</code>
<p>Lua unfortunatly (imo) likes to co-erce things into strings and numbers when it can without explicitly being told to do so.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Borasky</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-42818</link>
		<dc:creator>Ed Borasky</dc:creator>
		<pubDate>Sat, 05 Aug 2006 17:13:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-42818</guid>
		<description>Ah ... but you *wouldn't* write a web application in Perl, Python, PHP or Ruby (or Java, etc.) -- you'd write it in a *framework*, like Rails! The question isn't "How strict is your language?" The question is, "How good a web application programmer are you?" and "How well does your *framework* support designing secure, scalable, etc. web applications?"</description>
		<content:encoded><![CDATA[<p>Ah &#8230; but you *wouldn&#8217;t* write a web application in Perl, Python, PHP or Ruby (or Java, etc.) &#8212; you&#8217;d write it in a *framework*, like Rails! The question isn&#8217;t &#8220;How strict is your language?&#8221; The question is, &#8220;How good a web application programmer are you?&#8221; and &#8220;How well does your *framework* support designing secure, scalable, etc. web applications?&#8221;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Sascha Goebels WebLog &#187; Blog Archive &#187; How strict is your dynamic language</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-42780</link>
		<dc:creator>Sascha Goebels WebLog &#187; Blog Archive &#187; How strict is your dynamic language</dc:creator>
		<pubDate>Sat, 05 Aug 2006 12:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-42780</guid>
		<description>[...] http://www.sitepoint.com/  Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://www.sitepoint.com/" rel="nofollow">http://www.sitepoint.com/</a>  Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. [&#8230;]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: leeschen</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-42733</link>
		<dc:creator>leeschen</dc:creator>
		<pubDate>Sat, 05 Aug 2006 06:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-42733</guid>
		<description>Harry F wrote: "So one dividing line here is whether some kind of fatal error should be raised. Perl and PHP continue execution by default while Ruby and Python halt, unless you explicitly handle the problem. Which is better?"

This depends entirely on the nature of the error.  A major failure that is likely to really screw the works should abort with a truly meaningful message.  Many languages allow explicit handling of such events and these should be used where possible.  Not all possible error conditions can be forseen, but as many as can be should be given this treatment.

Lesser problems can usually be permitted to continue, though perhaps with a warning message and a return to an input field.  A custom error handler, such as that mentioned by Chris Adams can help with both types of problems, but I need to ask Chris if he uses it only during debug, or if it remains in the finished code.

Rob Walker makes an excellent point when he says, "The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues." 

There is a real problem with programs that continue with no error control.  Subtle errors can easily be introduced into data and soon an entire database is contaminated and totally useless.  My primary background is in database programing and, trust me, this is a type of problem you do not want to discover after a client has invested thousands of dollars in data collection/entry efforts.  If the language has no intrinsic method to validate data, the programmer must implicitly code data checking with appropriate action before that data is used or stored.

I prefer to accomplish this myself and specify the program response rather than depend only upon the language's intrinsic type checking.  I do have to admit, however, that I am rather a newcomer to web scripting, client or server, but this means I have no hard and fast favorites.  Right now I am improving my JavaScript and just beginning with PHP, so for the most part, I will just sit back and learn from y'all.

Lee Eschen</description>
		<content:encoded><![CDATA[<p>Harry F wrote: &#8220;So one dividing line here is whether some kind of fatal error should be raised. Perl and PHP continue execution by default while Ruby and Python halt, unless you explicitly handle the problem. Which is better?&#8221;</p>
<p>This depends entirely on the nature of the error.  A major failure that is likely to really screw the works should abort with a truly meaningful message.  Many languages allow explicit handling of such events and these should be used where possible.  Not all possible error conditions can be forseen, but as many as can be should be given this treatment.</p>
<p>Lesser problems can usually be permitted to continue, though perhaps with a warning message and a return to an input field.  A custom error handler, such as that mentioned by Chris Adams can help with both types of problems, but I need to ask Chris if he uses it only during debug, or if it remains in the finished code.</p>
<p>Rob Walker makes an excellent point when he says, &#8220;The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues.&#8221; </p>
<p>There is a real problem with programs that continue with no error control.  Subtle errors can easily be introduced into data and soon an entire database is contaminated and totally useless.  My primary background is in database programing and, trust me, this is a type of problem you do not want to discover after a client has invested thousands of dollars in data collection/entry efforts.  If the language has no intrinsic method to validate data, the programmer must implicitly code data checking with appropriate action before that data is used or stored.</p>
<p>I prefer to accomplish this myself and specify the program response rather than depend only upon the language&#8217;s intrinsic type checking.  I do have to admit, however, that I am rather a newcomer to web scripting, client or server, but this means I have no hard and fast favorites.  Right now I am improving my JavaScript and just beginning with PHP, so for the most part, I will just sit back and learn from y&#8217;all.</p>
<p>Lee Eschen</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Fenrir2</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41771</link>
		<dc:creator>Fenrir2</dc:creator>
		<pubDate>Tue, 01 Aug 2006 09:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41771</guid>
		<description>Ruby returns a nil if a value in a hash doesn't exist. This is useful if you want to check for a key:

&lt;code&gt;if name[:first]
   printName(name)
else
   puts 'No first name'
end&lt;/code&gt;

If you want a stricter behavior use Hash#fetch instead of Hash#[].

&lt;code&gt;def printName(name) 
   puts "Name is #{name.fetch :first} #{name.fetch :given}" 
end&lt;/code&gt;

Now the script will raise an IndexError.</description>
		<content:encoded><![CDATA[<p>Ruby returns a nil if a value in a hash doesn&#8217;t exist. This is useful if you want to check for a key:</p>
<code>if name[:first]
   printName(name)
else
   puts 'No first name'
end</code>
<p>If you want a stricter behavior use Hash#fetch instead of Hash#[].</p>
<code>def printName(name) 
   puts "Name is #{name.fetch :first} #{name.fetch :given}" 
end</code>
<p>Now the script will raise an IndexError.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: The New Guy</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41196</link>
		<dc:creator>The New Guy</dc:creator>
		<pubDate>Sat, 29 Jul 2006 12:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41196</guid>
		<description>I think the classification of weak/strong typing when expanded is a pretty good correctly placing the languages.

PHP and perl are weak/dynamic.
Ruby and python are strong/dynamic.

And just for contrast:

C++ is weak/static
Java is strong/static

In terms of error reporting, I think we have known for quite awhile that Ruby is pretty crappy at it.</description>
		<content:encoded><![CDATA[<p>I think the classification of weak/strong typing when expanded is a pretty good correctly placing the languages.</p>
<p>PHP and perl are weak/dynamic.<br />
Ruby and python are strong/dynamic.</p>
<p>And just for contrast:</p>
<p>C++ is weak/static<br />
Java is strong/static</p>
<p>In terms of error reporting, I think we have known for quite awhile that Ruby is pretty crappy at it.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: DerelictMan</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41090</link>
		<dc:creator>DerelictMan</dc:creator>
		<pubDate>Fri, 28 Jul 2006 21:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41090</guid>
		<description>Oops, I guess I didn't properly escape my tags in the code snippet above (there is apparently no way to preview your comments here); let me try again:

class Foo {}
$f = new Foo();
if (mt_rand(1, 100) == 1) $f-&#62;someMethod();

&lt;blockquote&gt;But in any case it should be a deliberate decision to let the program continue, not the default behavior of the language. The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues.&lt;/blockquote&gt;

Well put.  This is one of the reasons I've never been a fan of MySQL (but that's a whole other discussion...)</description>
		<content:encoded><![CDATA[<p>Oops, I guess I didn&#8217;t properly escape my tags in the code snippet above (there is apparently no way to preview your comments here); let me try again:</p>
<p>class Foo {}<br />
$f = new Foo();<br />
if (mt_rand(1, 100) == 1) $f-&gt;someMethod();</p>
<blockquote><p>But in any case it should be a deliberate decision to let the program continue, not the default behavior of the language. The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues.</p></blockquote>
<p>Well put.  This is one of the reasons I&#8217;ve never been a fan of MySQL (but that&#8217;s a whole other discussion&#8230;)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: DerelictMan</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41087</link>
		<dc:creator>DerelictMan</dc:creator>
		<pubDate>Fri, 28 Jul 2006 21:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41087</guid>
		<description>&lt;blockquote&gt;You can still consider dynamic languages appropriate in a FailFast context.&lt;/blockquote&gt;

Well, first of all, I was playing devil's advocate; I'm a fan of both dynamically-typed languages AND statically typed ones (different tools for different tasks).  I was attempting to point out the fact that FailFast isn't a black or white philosophy (as it seems that doug above is a fan of absolutes).  There are degrees of failing fast, and while it's a good general approach, obviously sometimes other considerations take priority.  

&lt;blockquote&gt;It’s not about type checking.&lt;/blockquote&gt;

I disagree.  It's not ONLY about type checking, but type errors *are* a common source of application bugs.  Catching a parameter with an incorrect type at the beginning of a method invocation (say, with a type hint) is "fail fast" when compared with not checking the type and then 20-30 lines of code later attempting to call an undefined method on that parameter.  If you are one to see "fail fast" as an absolute rule, then obviously you would prefer to know as soon as the method is called that the parameter type is wrong.  My contention is that if you take the fail fast philosophy to its extreme (which is probably ill-advised), you must find static, compile-time type checking to be the best approach (since that is about as early in the process as you can get), and you will have to abandon dynamically typed languages altogether.

Example (obviously contrived):
&lt;code&gt;
someMethod();
?&#62;
&lt;/code&gt;

This is perfectly legal PHP code, yet it will fail at runtime about half the time.  With static typing, the language would "know" that an error exists, and would refuse to compile it.  However, dynamically typed languages would accept the equivalent of the above code without any complaints.  Hence, they are not "failing fast".

However, clearly dynamically typed languages have some (or many, depending on whom you ask) advantages over statically typed ones in certain contexts.  My only point is that sometimes other concerns take priority over failing as fast as possible.</description>
		<content:encoded><![CDATA[<blockquote><p>You can still consider dynamic languages appropriate in a FailFast context.</p></blockquote>
<p>Well, first of all, I was playing devil&#8217;s advocate; I&#8217;m a fan of both dynamically-typed languages AND statically typed ones (different tools for different tasks).  I was attempting to point out the fact that FailFast isn&#8217;t a black or white philosophy (as it seems that doug above is a fan of absolutes).  There are degrees of failing fast, and while it&#8217;s a good general approach, obviously sometimes other considerations take priority.  </p>
<blockquote><p>It’s not about type checking.</p></blockquote>
<p>I disagree.  It&#8217;s not ONLY about type checking, but type errors *are* a common source of application bugs.  Catching a parameter with an incorrect type at the beginning of a method invocation (say, with a type hint) is &#8220;fail fast&#8221; when compared with not checking the type and then 20-30 lines of code later attempting to call an undefined method on that parameter.  If you are one to see &#8220;fail fast&#8221; as an absolute rule, then obviously you would prefer to know as soon as the method is called that the parameter type is wrong.  My contention is that if you take the fail fast philosophy to its extreme (which is probably ill-advised), you must find static, compile-time type checking to be the best approach (since that is about as early in the process as you can get), and you will have to abandon dynamically typed languages altogether.</p>
<p>Example (obviously contrived):<br />
<code>
someMethod();
?&gt;
</code></p>
<p>This is perfectly legal PHP code, yet it will fail at runtime about half the time.  With static typing, the language would &#8220;know&#8221; that an error exists, and would refuse to compile it.  However, dynamically typed languages would accept the equivalent of the above code without any complaints.  Hence, they are not &#8220;failing fast&#8221;.</p>
<p>However, clearly dynamically typed languages have some (or many, depending on whom you ask) advantages over statically typed ones in certain contexts.  My only point is that sometimes other concerns take priority over failing as fast as possible.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Walker</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41085</link>
		<dc:creator>Rob Walker</dc:creator>
		<pubDate>Fri, 28 Jul 2006 21:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41085</guid>
		<description>P.S. I think the second two paragraphs I wrote might be unclear.

It *is* about undiscovered errors in the sense that although continuing after an error is in some cases desireable, the rule and not the exception is that it's best not to do so.

But in any case it should be a deliberate decision to let the program continue, not the default behavior of the language. The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues. Halting the program is one obvious way to prevent that.

I believe a language should trust the programmer to know when to catch an error and when to let it pass. But to do that, the programmer must at least be given the decision first.

From The Zen of Python:

Errors should never pass silently.
Unless explicitly silenced.</description>
		<content:encoded><![CDATA[<p>P.S. I think the second two paragraphs I wrote might be unclear.</p>
<p>It *is* about undiscovered errors in the sense that although continuing after an error is in some cases desireable, the rule and not the exception is that it&#8217;s best not to do so.</p>
<p>But in any case it should be a deliberate decision to let the program continue, not the default behavior of the language. The last thing you want is to believe everything is fine meanwhile your data is quietly getting corrupted as the program continues. Halting the program is one obvious way to prevent that.</p>
<p>I believe a language should trust the programmer to know when to catch an error and when to let it pass. But to do that, the programmer must at least be given the decision first.</p>
<p>From The Zen of Python:</p>
<p>Errors should never pass silently.<br />
Unless explicitly silenced.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Walker</title>
		<link>http://www.sitepoint.com/blogs/2006/07/27/how-strict-is-your-dynamic-language/#comment-41078</link>
		<dc:creator>Rob Walker</dc:creator>
		<pubDate>Fri, 28 Jul 2006 21:12:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1651#comment-41078</guid>
		<description>You can still consider dynamic languages appropriate in a FailFast context. It's not about type checking. It's not about undiscovered errors. It's about what happens when the language knows an error occurred, whether or not it's due to a type error, and whether or not it raised an error for a variable that was binded late or early. Either the program is allowed to continue or it's halted after an error.

If an error is consistent in its behavior and causes, then it's easier to find and fix, and you can be more confident your code isn't a mess. It's just a simple bug.

If an error is sporadic and there seems to be little rhyme or reason to its causes and effects, the bug is harder to fix. It's also a reason to start wondering if there aren't many other subtle problems with your code.

Just my two cents.</description>
		<content:encoded><![CDATA[<p>You can still consider dynamic languages appropriate in a FailFast context. It&#8217;s not about type checking. It&#8217;s not about undiscovered errors. It&#8217;s about what happens when the language knows an error occurred, whether or not it&#8217;s due to a type error, and whether or not it raised an error for a variable that was binded late or early. Either the program is allowed to continue or it&#8217;s halted after an error.</p>
<p>If an error is consistent in its behavior and causes, then it&#8217;s easier to find and fix, and you can be more confident your code isn&#8217;t a mess. It&#8217;s just a simple bug.</p>
<p>If an error is sporadic and there seems to be little rhyme or reason to its causes and effects, the bug is harder to fix. It&#8217;s also a reason to start wondering if there aren&#8217;t many other subtle problems with your code.</p>
<p>Just my two cents.</p>]]></content:encoded>
	</item>
</channel>
</rss>
