<?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: Optional typing and dynamic languages</title>
	<atom:link href="http://almaer.com/blog/optional-typing-and-dynamic-languages/feed" rel="self" type="application/rss+xml" />
	<link>http://almaer.com/blog/optional-typing-and-dynamic-languages</link>
	<description>blogging about life, the universe, and everything tech</description>
	<lastBuildDate>Sat, 08 Sep 2012 07:06:53 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ray Cromwell</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39447</link>
		<dc:creator>Ray Cromwell</dc:creator>
		<pubDate>Wed, 20 Aug 2008 09:13:20 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39447</guid>
		<description>Nosredna, I believe most of these IDEs are using a combination of three techniques: 1) intrinsic DB of most browser methods (e.g. document.*), this is how IntelliJ IDEA does it, you can even edit the database. 2) detection of idiomatic Javascript patterns, e.g. foo.bar.Baz.prototype.method = expression = &quot;early binding&quot; static function definition, the IDE will detect this and treat it as an early-bound method on Baz. 3) Limited type-flow, that is if var a = new Baz(), and you invoke foo(a), and foo invokes bar(a), then bar()&#039;s argument will be assumed to be of type Baz. It doesn&#039;t need to run the code to do this, it can just build a CFG of the code. 

I&#039;ve yet to see a JS IDE work like Smalltalk/Forth/Factor/etc in the sense that you edit with respect to the current memory image of the interpreter.


Hibberd, static languages with optional types differ somewhat from dynamic languages with optional types.  With static languages that include type inferencing, like those based on ML, you omit type declarations, but you do not forfeit strong typing nor performance. Methods without types merely become parametric.

For example,

add(x, y) = x + y

If called as add(1,2) it compiles as add(int,int), if called with add(1.2, 2.3) it compiles as add(double,double), and if called with add(1.2, &quot;Foo&quot;) it throws a compile error because in this case, the intrinsic &quot;+&quot; operator doesn&#039;t support (int,String) are parameters.</description>
		<content:encoded><![CDATA[<p>Nosredna, I believe most of these IDEs are using a combination of three techniques: 1) intrinsic DB of most browser methods (e.g. document.*), this is how IntelliJ IDEA does it, you can even edit the database. 2) detection of idiomatic Javascript patterns, e.g. foo.bar.Baz.prototype.method = expression = &#8220;early binding&#8221; static function definition, the IDE will detect this and treat it as an early-bound method on Baz. 3) Limited type-flow, that is if var a = new Baz(), and you invoke foo(a), and foo invokes bar(a), then bar()&#8217;s argument will be assumed to be of type Baz. It doesn&#8217;t need to run the code to do this, it can just build a CFG of the code. </p>
<p>I&#8217;ve yet to see a JS IDE work like Smalltalk/Forth/Factor/etc in the sense that you edit with respect to the current memory image of the interpreter.</p>
<p>Hibberd, static languages with optional types differ somewhat from dynamic languages with optional types.  With static languages that include type inferencing, like those based on ML, you omit type declarations, but you do not forfeit strong typing nor performance. Methods without types merely become parametric.</p>
<p>For example,</p>
<p>add(x, y) = x + y</p>
<p>If called as add(1,2) it compiles as add(int,int), if called with add(1.2, 2.3) it compiles as add(double,double), and if called with add(1.2, &#8220;Foo&#8221;) it throws a compile error because in this case, the intrinsic &#8220;+&#8221; operator doesn&#8217;t support (int,String) are parameters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39440</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Tue, 19 Aug 2008 17:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39440</guid>
		<description>I&#039;m not sure how often you other JavaScript programmers jump around through the new IDEs, but I noticed that a couple I tried recently (I think Komodo and NetBeans) do an amazing job of keeping track of the types in JavaScript. They must almost be running your code! It&#039;s very impressive. Even though you aren&#039;t telling them the types, they are looking at your code to figure out the types, and are as strict in warning you as Flex 3 is with AS3.

To extend my previous wish, I think AS3 and JS could almost be merged in the IDEs. A &quot;show types&quot; option could work in either AS3 (optional hiding) or JS (optional showing).</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure how often you other JavaScript programmers jump around through the new IDEs, but I noticed that a couple I tried recently (I think Komodo and NetBeans) do an amazing job of keeping track of the types in JavaScript. They must almost be running your code! It&#8217;s very impressive. Even though you aren&#8217;t telling them the types, they are looking at your code to figure out the types, and are as strict in warning you as Flex 3 is with AS3.</p>
<p>To extend my previous wish, I think AS3 and JS could almost be merged in the IDEs. A &#8220;show types&#8221; option could work in either AS3 (optional hiding) or JS (optional showing).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Hibberd</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39439</link>
		<dc:creator>Mark Hibberd</dc:creator>
		<pubDate>Tue, 19 Aug 2008 13:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39439</guid>
		<description>Optional type systems really seem to add a bunch of complexity for little gain. I feel languages really need to pick one way and go for it. If the language has dynamic goodness then forget the types, if it is statically typed hope for some good inferencing a la haskell.

The language that really gets me is groovy. Not only does it have optional types. If you use them, the code is slower and they do not get checked up front so you can still assign &#039;Bar b = new Foo()&#039; even if they are totally incompatible, it will then fail at runtime at the same place it would have without the type.</description>
		<content:encoded><![CDATA[<p>Optional type systems really seem to add a bunch of complexity for little gain. I feel languages really need to pick one way and go for it. If the language has dynamic goodness then forget the types, if it is statically typed hope for some good inferencing a la haskell.</p>
<p>The language that really gets me is groovy. Not only does it have optional types. If you use them, the code is slower and they do not get checked up front so you can still assign &#8216;Bar b = new Foo()&#8217; even if they are totally incompatible, it will then fail at runtime at the same place it would have without the type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Holton</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39436</link>
		<dc:creator>Mark Holton</dc:creator>
		<pubDate>Mon, 18 Aug 2008 22:35:19 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39436</guid>
		<description>Ray, even with a compiler, you still have to write the tests.  Irresponsible developers will have a compiler, and will still be missing tests.  I don&#039;t think that necessarily moves you forward.  My two cents.  

...try Screw-Unit for JavaScript BDD... if you like RSpec for Ruby, you&#039;ll like it:

http://github.com/nkallen/screw-unit/tree/master
http://github.com/nkallen/screw-unit/tree/master/README.markdown</description>
		<content:encoded><![CDATA[<p>Ray, even with a compiler, you still have to write the tests.  Irresponsible developers will have a compiler, and will still be missing tests.  I don&#8217;t think that necessarily moves you forward.  My two cents.  </p>
<p>&#8230;try Screw-Unit for JavaScript BDD&#8230; if you like RSpec for Ruby, you&#8217;ll like it:</p>
<p><a href="http://github.com/nkallen/screw-unit/tree/master" rel="nofollow">http://github.com/nkallen/screw-unit/tree/master</a><br />
<a href="http://github.com/nkallen/screw-unit/tree/master/README.markdown" rel="nofollow">http://github.com/nkallen/screw-unit/tree/master/README.markdown</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dion</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39434</link>
		<dc:creator>dion</dc:creator>
		<pubDate>Mon, 18 Aug 2008 22:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39434</guid>
		<description>I have always liked the idea of giving the IDE power to hide things and such. We already have that with hiding blocks / comments etc.

I would like to see this taken further and have my view on top of the data, which can be tweaked. E.g. I can set my brace style and even if it is different from the code, I see it how I like it. This fits into the same problem.</description>
		<content:encoded><![CDATA[<p>I have always liked the idea of giving the IDE power to hide things and such. We already have that with hiding blocks / comments etc.</p>
<p>I would like to see this taken further and have my view on top of the data, which can be tweaked. E.g. I can set my brace style and even if it is different from the code, I see it how I like it. This fits into the same problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Cromwell</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39433</link>
		<dc:creator>Ray Cromwell</dc:creator>
		<pubDate>Mon, 18 Aug 2008 20:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39433</guid>
		<description>The common response to the refactoring question is &quot;write more tests&quot;, but the Javascript community doesn&#039;t seem to be listening, as most Javascript applications I encounter seem to have little to no tests with obvious exceptions to big popular community projects (like Dojo). And the code coverage compares poorly with Java. This seems to be the case even though unit tests are easier to write in Javascript then in Java and more important to have in Javascript!

I like Nosredna&#039;s suggesting. Allow the IDE a &quot;hidden types&quot; mode where you don&#039;t see the declarations. Come to think of it, they could do this for Java as well in many cases. I proposed something similar in the Java Closures debate, which is implement a Java IDE extension which shows BGGA Closures as Anonymous Inner Classes for those who prefer more verbosity.

I think choice is best. I&#039;m surprised that many people want to take away choice from others based on their own personal aesthetic preferences.</description>
		<content:encoded><![CDATA[<p>The common response to the refactoring question is &#8220;write more tests&#8221;, but the Javascript community doesn&#8217;t seem to be listening, as most Javascript applications I encounter seem to have little to no tests with obvious exceptions to big popular community projects (like Dojo). And the code coverage compares poorly with Java. This seems to be the case even though unit tests are easier to write in Javascript then in Java and more important to have in Javascript!</p>
<p>I like Nosredna&#8217;s suggesting. Allow the IDE a &#8220;hidden types&#8221; mode where you don&#8217;t see the declarations. Come to think of it, they could do this for Java as well in many cases. I proposed something similar in the Java Closures debate, which is implement a Java IDE extension which shows BGGA Closures as Anonymous Inner Classes for those who prefer more verbosity.</p>
<p>I think choice is best. I&#8217;m surprised that many people want to take away choice from others based on their own personal aesthetic preferences.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Holton</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39430</link>
		<dc:creator>Mark Holton</dc:creator>
		<pubDate>Mon, 18 Aug 2008 17:01:33 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39430</guid>
		<description>I like dynamic typing all the way.  Esp for the web.  Let me ask it if it quacks like a duck.  Dynamic languages are meritocracies -- we only care about what they *do*, not where they&#039;re from.  If you have sufficient tests in your app, it&#039;s safe to refactor.  Thinking the compiler is a panacea prevents you from writing more tests.  Write more tests, and smell them often!</description>
		<content:encoded><![CDATA[<p>I like dynamic typing all the way.  Esp for the web.  Let me ask it if it quacks like a duck.  Dynamic languages are meritocracies &#8212; we only care about what they *do*, not where they&#8217;re from.  If you have sufficient tests in your app, it&#8217;s safe to refactor.  Thinking the compiler is a panacea prevents you from writing more tests.  Write more tests, and smell them often!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39429</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Mon, 18 Aug 2008 09:52:20 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39429</guid>
		<description>I wish the IDEs had a toggle that let me see the types or not.</description>
		<content:encoded><![CDATA[<p>I wish the IDEs had a toggle that let me see the types or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Cromwell</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39419</link>
		<dc:creator>Ray Cromwell</dc:creator>
		<pubDate>Fri, 15 Aug 2008 18:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39419</guid>
		<description>Dion, you are confusing lack of type inferencing with type declarations. It&#039;s perfectly possible to have function type parameters, but not have to declare any types on local variables. As often the case in discussions of typing, opponents often cite boilerplate laden languages like Java, but ignore how types work in ML/Haskell/Scala/etc. Just because some people are overzealous with respect to type annotations should not be a strike against the feature. Every feature can be misused.

On the performance side of typing, the conclusion does not follow from the evidence. That is, the fact that adding an int type annotation caused a performance regression in Adobe&#039;s VM implementation, does not mean that type information always leads to poorer performance vs a trace-jit, nor does it mean that the regressions would happen on every VM implementation that leverages type information. There is no a priori reason why a tracing-jit could not also leverage type information as well.

Optimizers are often brittle, and some perturbations cause large regressions. We see this in every language, and you will see it in Tracing JavaScript VMs, that certain constructs will thwart optimizations, which will lead to lots of guides like &quot;How to write optimal Javascript for Tracing JITs&quot;

There are many reasons why types help:

1) performance. Java Hotspot has some characteristics of a trace JIT, more in the vein of the original Self implementation, collecting type feedback and profile information to yield speculative optimizations with guards. It would be instructive to compare JS trace-jits not just against Tamarin, but against Silverlight CLR and JavaFX.  Tracing JITs are being oversold. It&#039;s true they are a massive improvement, but they are not going to be winning any language performance shootouts against statically compiled languages.  HotSpot was oversold (as was Self) when originally released. Proponents were citing scenarios where it would beat C, but the reality is, it still doesn&#039;t.

2) IDE toolchain. Navigating large code bases and doing safe refactorings are just alot easier to do with types. Types don&#039;t make sense if you&#039;ve only got 100 lines of code, but if you&#039;re &quot;programming in the large&quot; with libraries containing hundreds or thousands of functions, it makes alot of sense.  The lack of a standard package/module/namespace system in JS is a crime.
 
3) Self documenting. The types provide the ability to automatically generate mostly useful documentation, as well as allow programmers to quickly check expectations.

4) &quot;on the wire size&quot;. Trace JITs can help performance, but the optimizations can only be applied *after* the application has been downloaded. With people delivering JS code bases in upwards of 500k, the lack of a package/module system with early binding makes it hard to design preprocessors that strip unused code from the script. GWT, for example, shows how awesome this can become, reducing code size by a factor of 100 in some cases.  The result is that everyone roles their own module/build system for concatenating scripts, and inter-library reuse and packaging is reduced.

I personally find that I can deal with missing types for small code bases, but when you get to something like a Google Spreadsheets or GMail app, the lack of types really starts to inhibit productivity. And I would assume that Google agrees, otherwise they would have never built their Javascript compiler, and you would not see /*type*/ stuff showing up in their idiomatic Javascript libraries.

When you see people putting semantically functional data in code comments, it tends to indicate a flaw in the language.</description>
		<content:encoded><![CDATA[<p>Dion, you are confusing lack of type inferencing with type declarations. It&#8217;s perfectly possible to have function type parameters, but not have to declare any types on local variables. As often the case in discussions of typing, opponents often cite boilerplate laden languages like Java, but ignore how types work in ML/Haskell/Scala/etc. Just because some people are overzealous with respect to type annotations should not be a strike against the feature. Every feature can be misused.</p>
<p>On the performance side of typing, the conclusion does not follow from the evidence. That is, the fact that adding an int type annotation caused a performance regression in Adobe&#8217;s VM implementation, does not mean that type information always leads to poorer performance vs a trace-jit, nor does it mean that the regressions would happen on every VM implementation that leverages type information. There is no a priori reason why a tracing-jit could not also leverage type information as well.</p>
<p>Optimizers are often brittle, and some perturbations cause large regressions. We see this in every language, and you will see it in Tracing JavaScript VMs, that certain constructs will thwart optimizations, which will lead to lots of guides like &#8220;How to write optimal Javascript for Tracing JITs&#8221;</p>
<p>There are many reasons why types help:</p>
<p>1) performance. Java Hotspot has some characteristics of a trace JIT, more in the vein of the original Self implementation, collecting type feedback and profile information to yield speculative optimizations with guards. It would be instructive to compare JS trace-jits not just against Tamarin, but against Silverlight CLR and JavaFX.  Tracing JITs are being oversold. It&#8217;s true they are a massive improvement, but they are not going to be winning any language performance shootouts against statically compiled languages.  HotSpot was oversold (as was Self) when originally released. Proponents were citing scenarios where it would beat C, but the reality is, it still doesn&#8217;t.</p>
<p>2) IDE toolchain. Navigating large code bases and doing safe refactorings are just alot easier to do with types. Types don&#8217;t make sense if you&#8217;ve only got 100 lines of code, but if you&#8217;re &#8220;programming in the large&#8221; with libraries containing hundreds or thousands of functions, it makes alot of sense.  The lack of a standard package/module/namespace system in JS is a crime.</p>
<p>3) Self documenting. The types provide the ability to automatically generate mostly useful documentation, as well as allow programmers to quickly check expectations.</p>
<p>4) &#8220;on the wire size&#8221;. Trace JITs can help performance, but the optimizations can only be applied *after* the application has been downloaded. With people delivering JS code bases in upwards of 500k, the lack of a package/module system with early binding makes it hard to design preprocessors that strip unused code from the script. GWT, for example, shows how awesome this can become, reducing code size by a factor of 100 in some cases.  The result is that everyone roles their own module/build system for concatenating scripts, and inter-library reuse and packaging is reduced.</p>
<p>I personally find that I can deal with missing types for small code bases, but when you get to something like a Google Spreadsheets or GMail app, the lack of types really starts to inhibit productivity. And I would assume that Google agrees, otherwise they would have never built their Javascript compiler, and you would not see /*type*/ stuff showing up in their idiomatic Javascript libraries.</p>
<p>When you see people putting semantically functional data in code comments, it tends to indicate a flaw in the language.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike chambers</title>
		<link>http://almaer.com/blog/optional-typing-and-dynamic-languages/comment-page-1#comment-39418</link>
		<dc:creator>mike chambers</dc:creator>
		<pubDate>Fri, 15 Aug 2008 18:05:47 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/optional-typing-and-dynamic-languages#comment-39418</guid>
		<description>&gt;The speed difference may not matter in your app

It matters a lot when you start to talk about more expressive applications and experiences (including 3d). Just ask the papervision 3d guys:

http://blog.papervision3d.org/category/demos/

&gt;It will matter less and less in the future.

My experience working in the Flash community over the years is that to more processing power there is, the more developers and designers will push the boundry of what has been possible. Again, papervision 3d is a good example. It is a complete 3d engine implimented entirely in ActionScript, as is some of the image processing stuff (PNG, JPG encoding) made possible due to performance improvements in AS3.

But yes, for run of the mill apps, with buttons and forms, there is only so much processing power you need. Although, even in that case, more processing power and performance means that you can deal with much larger data sets, and do more advanced data manipulations.

mike chambers

mesh@adobe.com</description>
		<content:encoded><![CDATA[<p>&gt;The speed difference may not matter in your app</p>
<p>It matters a lot when you start to talk about more expressive applications and experiences (including 3d). Just ask the papervision 3d guys:</p>
<p><a href="http://blog.papervision3d.org/category/demos/" rel="nofollow">http://blog.papervision3d.org/category/demos/</a></p>
<p>&gt;It will matter less and less in the future.</p>
<p>My experience working in the Flash community over the years is that to more processing power there is, the more developers and designers will push the boundry of what has been possible. Again, papervision 3d is a good example. It is a complete 3d engine implimented entirely in ActionScript, as is some of the image processing stuff (PNG, JPG encoding) made possible due to performance improvements in AS3.</p>
<p>But yes, for run of the mill apps, with buttons and forms, there is only so much processing power you need. Although, even in that case, more processing power and performance means that you can deal with much larger data sets, and do more advanced data manipulations.</p>
<p>mike chambers</p>
<p><a href="mailto:mesh@adobe.com">mesh@adobe.com</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
