<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>techno.blog(&#34;Dion&#34;) &#187; actionscript</title>
	<atom:link href="http://almaer.com/blog/tag/actionscript/feed" rel="self" type="application/rss+xml" />
	<link>http://almaer.com/blog</link>
	<description>blogging about life, the universe, and everything tech</description>
	<lastBuildDate>Tue, 28 Aug 2012 14:41:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Optional typing and dynamic languages</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages</link>
		<comments>http://almaer.com/blog/optional-typing-and-dynamic-languages#comments</comments>
		<pubDate>Fri, 15 Aug 2008 16:52:19 +0000</pubDate>
		<dc:creator>dion</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ecmascript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages</guid>
		<description><![CDATA[After listening to Brendan talk about typing on the latest Open Web Podcast episode on ECMAScript Harmony it got me thinking again about optional typing.
It has always bugged me a little to think of type information in my nice clean dynamic languages (Ruby, JavaScript, Python, Perl, etc.).
Looking at even the simplest of code like this [...]]]></description>
			<content:encoded><![CDATA[<p>After listening to Brendan talk about typing on the <a href="http://openwebpodcast.com/episode-2-brendan-eich-and-arun-ranganathan-on-ecmascript-harmony">latest Open Web Podcast episode on ECMAScript Harmony</a> it got me thinking again about optional typing.</p>
<p>It has always bugged me a little to think of type information in my nice clean dynamic languages (Ruby, JavaScript, Python, Perl, etc.).</p>
<p>Looking at even the simplest of code like this (taken from Mike Chamber&#8217;s <a href="http://www.mikechambers.com/blog/2008/08/14/connecting-to-an-xmpp-jabber-server-with-the-xiff-as3-library/">XMPP server in ActionScript 3</a>)</p>
<pre language="javascript">
var room:Room = new Room(connection);
</pre>
<p>It irks me. Just work out that it is a room already won&#8217;t you? I know you can do it? You CAN do it. So, leave it out in this case.</p>
<p>Although the type information is optional, it seems that a lot of the code that I have seen in AS3 puts types in all over the place. I somewhat like the idea of using types when you really need them, such as for clear documentation of a core library, or some performance issue that you find is an issue (note: that becomes an issue, not one that is assumed!)</p>
<p>Once you open the door though, can people play that way? Is giving the programmer a bit switch of &#8220;shall I put the type in here?&#8221; every few seconds a good thing? Especially when the tools try to put the type in all the time?</p>
<p>I also found it very interesting when Brendan talked about how adding type information can actually hurt performance, sharing an example of when <code>var foo:int</code> doesn&#8217;t do what you actually need. For me, performance is pretty much out of the window, now, and definitely in the future.</p>
<p>So, I lean towards not needing it. But then I flip over the cards and see stuff like this (note: a mock example):</p>
<pre language="javascript">
/**
 * @type Room
 */
var room = new Room(connection);
</pre>
<p>Ugh. Now we have the worst of all words. We are documenting the code out of band. This is often done for some jsdoc-like tool that will generate docs for you. The problems are:</p>
<ul>
<li>The language itself has no idea about this information. The compiler. Nor, runtime. If there was something that could be done for performance, it couldn&#8217;t be</li>
<li>How easy would it be to get this out of date. If you change the type no one is going to complain. There is no validation here.</li>
<li>Way more verbose!</li>
</ul>
<p>This alone makes me think that I would rather have optional types just to avoid any hacks like this.</p>
<p>You?</p>
]]></content:encoded>
			<wfw:commentRss>http://almaer.com/blog/optional-typing-and-dynamic-languages/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>
