<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Explicit Static Types are not for the Compiler, but for the Developer - Duh</title>
	<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/</link>
	<description>Productivity in software development</description>
	<pubDate>Sun, 12 Oct 2008 23:38:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: stephan</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-41694</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Thu, 29 Nov 2007 21:49:29 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-41694</guid>
		<description>"If I want to know it I move my mouse cursor above “person” and I’ll see a popup-window that tells me what exact type “person” has."

How is your IDE accomplishing that I wonder without knowing the type.</description>
		<content:encoded><![CDATA[<p>&#8220;If I want to know it I move my mouse cursor above “person” and I’ll see a popup-window that tells me what exact type “person” has.&#8221;</p>
<p>How is your IDE accomplishing that I wonder without knowing the type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthias</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-41619</link>
		<dc:creator>Matthias</dc:creator>
		<pubDate>Thu, 29 Nov 2007 10:14:37 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-41619</guid>
		<description>"Is person of class Person? Or perhaps Student or Employee?"

In most cases the answer is: Who cares?
If I want to know it I move my mouse cursor above "person" and I'll see a popup-window that tells me what exact type "person" has.


"Explicit typing is writing documentation."

IMO documenting things I'm not interested in. Why should I care whether it's a "Person" or a "Nameable" as long as I can call "printName" with it? If I can't the compiler will tell me why I can't.

When I see code like

def nameable = new Person();  
printName(nameable);

I directly understand what it does.

I know that it fullfills the "contract" needed by "printName" as I wouldn't be able to compile it otherwise.
If whatever nameable is does not fullfill the contract the compiler will tell me what's wrong.

In my experience this works perfectly in other languages with type inference so I don't see why it shouldn't in Boo (with 'I never used).</description>
		<content:encoded><![CDATA[<p>&#8220;Is person of class Person? Or perhaps Student or Employee?&#8221;</p>
<p>In most cases the answer is: Who cares?<br />
If I want to know it I move my mouse cursor above &#8220;person&#8221; and I&#8217;ll see a popup-window that tells me what exact type &#8220;person&#8221; has.</p>
<p>&#8220;Explicit typing is writing documentation.&#8221;</p>
<p>IMO documenting things I&#8217;m not interested in. Why should I care whether it&#8217;s a &#8220;Person&#8221; or a &#8220;Nameable&#8221; as long as I can call &#8220;printName&#8221; with it? If I can&#8217;t the compiler will tell me why I can&#8217;t.</p>
<p>When I see code like</p>
<p>def nameable = new Person();<br />
printName(nameable);</p>
<p>I directly understand what it does.</p>
<p>I know that it fullfills the &#8220;contract&#8221; needed by &#8220;printName&#8221; as I wouldn&#8217;t be able to compile it otherwise.<br />
If whatever nameable is does not fullfill the contract the compiler will tell me what&#8217;s wrong.</p>
<p>In my experience this works perfectly in other languages with type inference so I don&#8217;t see why it shouldn&#8217;t in Boo (with &#8216;I never used).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: On type inference and redundant type declarations &#171; codeflo.ws</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37579</link>
		<dc:creator>On type inference and redundant type declarations &#171; codeflo.ws</dc:creator>
		<pubDate>Tue, 06 Nov 2007 19:43:57 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37579</guid>
		<description>[...] Tagged compilers, java, scala, static-typing, type-inference    Stephan Schmidt has a blog entry on how explicit static type declarations are for the benefit of the developer, and not the compiler. That is, when you have something like this: Person person = mysteriousCall() [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Tagged compilers, java, scala, static-typing, type-inference    Stephan Schmidt has a blog entry on how explicit static type declarations are for the benefit of the developer, and not the compiler. That is, when you have something like this: Person person = mysteriousCall() [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37571</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Tue, 06 Nov 2007 17:04:37 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37571</guid>
		<description>@Jari: Good to know that I could do : Nameable in Scala, one of my side projects is looking into lift.

A smart IDE should know about the type, you're right. But someone reading source outside an IDE, browsing through a repository with FishEye, using diff tools etc. will not benefit from the IDE knowledge. *Doc tools will also be much harder to write, which could lead to less documentation because the tool is not smart enough.

But I'm with you mostly, an IDE should hide or remove parts (existing things like generics, public modifiers come to mind) of code and just show them when you need them. On the other hand, when the IDE hides code and shows annotations, it's not important anymore for the developer if the code is there or not (in real, in source). If I can hide the type, I do not care if I have added it with auto completion. &lt;b&gt;Auto completion could just add the type for you without any typing just by type inference :-)&lt;/b&gt;. And then I don't care if the source has the type or not.</description>
		<content:encoded><![CDATA[<p>@Jari: Good to know that I could do : Nameable in Scala, one of my side projects is looking into lift.</p>
<p>A smart IDE should know about the type, you&#8217;re right. But someone reading source outside an IDE, browsing through a repository with FishEye, using diff tools etc. will not benefit from the IDE knowledge. *Doc tools will also be much harder to write, which could lead to less documentation because the tool is not smart enough.</p>
<p>But I&#8217;m with you mostly, an IDE should hide or remove parts (existing things like generics, public modifiers come to mind) of code and just show them when you need them. On the other hand, when the IDE hides code and shows annotations, it&#8217;s not important anymore for the developer if the code is there or not (in real, in source). If I can hide the type, I do not care if I have added it with auto completion. <b>Auto completion could just add the type for you without any typing just by type inference :-)</b>. And then I don&#8217;t care if the source has the type or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jari Aarniala</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37527</link>
		<dc:creator>Jari Aarniala</dc:creator>
		<pubDate>Tue, 06 Nov 2007 10:02:46 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37527</guid>
		<description>Well, in a language such as Scala, if you really need to narrow the type to Nameable, it's not a problem:


def nameable: Nameable = new Person()


I for one *do* think that type declarations are redundant when they can be inferred. A smart IDE, working in conjunction with an incremental compiler (a la Eclipse), could just decorate the code view with the inferred type of the member you're looking at, e.g.


[Person] def person = getPerson


i.e. show the type of the member without the developer having to type it down redundantly. WDYT?</description>
		<content:encoded><![CDATA[<p>Well, in a language such as Scala, if you really need to narrow the type to Nameable, it&#8217;s not a problem:</p>
<p>def nameable: Nameable = new Person()</p>
<p>I for one *do* think that type declarations are redundant when they can be inferred. A smart IDE, working in conjunction with an incremental compiler (a la Eclipse), could just decorate the code view with the inferred type of the member you&#8217;re looking at, e.g.</p>
<p>[Person] def person = getPerson</p>
<p>i.e. show the type of the member without the developer having to type it down redundantly. WDYT?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37509</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Tue, 06 Nov 2007 08:17:36 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37509</guid>
		<description>@Ricky: I thought about your comment for some time, perhaps you're right and I should not car what getCurrent() returns, as long as it's typed and the compiler (and my IDE) know what type it is.

And perhaps you've got me wrong, I'm not against type inference. I wish Java was more clever with types. But I'm against dropping explicit types. I often see this with dynamic code:

&lt;pre name="code" class="java:nocontrols:nogutter"&gt;
// List of &#60;Order&#62;
def calculate(orders)
&lt;/pre&gt;

or

&lt;pre name="code" class="java:nocontrols:nogutter"&gt;
// Returns List of &#60;Order&#62;
def orders = getOrders()
&lt;/pre&gt;

where people add the type in a comment to document their code.

@Greg: "Your IDE could also tell you the types of things inline."

&lt;pre name="code" class="java:nocontrols:nogutter"&gt;
Nameable nameable = new Person()
&lt;/pre&gt;

The IDE can't decide which type I want. 

This is just some kind of design by contract, where I have a type contract for my code. The explicit declaration of what my code expects, in this case a Nameable.

&lt;pre name="code" class="java:nocontrols:nogutter"&gt;
def nameable = new Person()
&lt;/pre&gt;

does not declare such a contract for my code. The code following this line has no declared expectations about the nameable variable.</description>
		<content:encoded><![CDATA[<p>@Ricky: I thought about your comment for some time, perhaps you&#8217;re right and I should not car what getCurrent() returns, as long as it&#8217;s typed and the compiler (and my IDE) know what type it is.</p>
<p>And perhaps you&#8217;ve got me wrong, I&#8217;m not against type inference. I wish Java was more clever with types. But I&#8217;m against dropping explicit types. I often see this with dynamic code:</p>
<pre name="code" class="java:nocontrols:nogutter">
// List of &lt;Order&gt;
def calculate(orders)
</pre>
<p>or</p>
<pre name="code" class="java:nocontrols:nogutter">
// Returns List of &lt;Order&gt;
def orders = getOrders()
</pre>
<p>where people add the type in a comment to document their code.</p>
<p>@Greg: &#8220;Your IDE could also tell you the types of things inline.&#8221;</p>
<pre name="code" class="java:nocontrols:nogutter">
Nameable nameable = new Person()
</pre>
<p>The IDE can&#8217;t decide which type I want. </p>
<p>This is just some kind of design by contract, where I have a type contract for my code. The explicit declaration of what my code expects, in this case a Nameable.</p>
<pre name="code" class="java:nocontrols:nogutter">
def nameable = new Person()
</pre>
<p>does not declare such a contract for my code. The code following this line has no declared expectations about the nameable variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37494</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Tue, 06 Nov 2007 05:57:32 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37494</guid>
		<description>"The same IDE-using developer is certainly able to glance at the original method to see what types it has, and maybe just hover over the variable declaration to see what type the inference has given it."

public String createIdentifiier(id);

Could you tell me the type of id?

def getPerson() {
   return Factory.getPerson();
}

Could you tell me the return type? I can't. And the call chain could be much more complex so it would take more and more time to just check the types. And decide for the correct subtype or interface of the return type.

"person is a fairly meaningless variable name. You’re actually duplicating the type in the name, when you probably would be better off picking a better name, or getting rid of the name"

So, what is a better name? Current? I can't see how

def current = Factory.getPerson()

makes anything more clear.

Peace
-stephan</description>
		<content:encoded><![CDATA[<p>&#8220;The same IDE-using developer is certainly able to glance at the original method to see what types it has, and maybe just hover over the variable declaration to see what type the inference has given it.&#8221;</p>
<p>public String createIdentifiier(id);</p>
<p>Could you tell me the type of id?</p>
<p>def getPerson() {<br />
   return Factory.getPerson();<br />
}</p>
<p>Could you tell me the return type? I can&#8217;t. And the call chain could be much more complex so it would take more and more time to just check the types. And decide for the correct subtype or interface of the return type.</p>
<p>&#8220;person is a fairly meaningless variable name. You’re actually duplicating the type in the name, when you probably would be better off picking a better name, or getting rid of the name&#8221;</p>
<p>So, what is a better name? Current? I can&#8217;t see how</p>
<p>def current = Factory.getPerson()</p>
<p>makes anything more clear.</p>
<p>Peace<br />
-stephan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg M</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37482</link>
		<dc:creator>Greg M</dc:creator>
		<pubDate>Tue, 06 Nov 2007 03:23:07 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37482</guid>
		<description>Static types are documentation, yes. That's still no reason to write them yourself. Your IDE could also tell you the types of things inline. On the other hand, I think declaring the type at the top of a function is good practice, so your compiler can better pinpoint _where_ your type error is when you get something wrong.</description>
		<content:encoded><![CDATA[<p>Static types are documentation, yes. That&#8217;s still no reason to write them yourself. Your IDE could also tell you the types of things inline. On the other hand, I think declaring the type at the top of a function is good practice, so your compiler can better pinpoint _where_ your type error is when you get something wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ricky Clarkson</title>
		<link>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37415</link>
		<dc:creator>Ricky Clarkson</dc:creator>
		<pubDate>Mon, 05 Nov 2007 20:36:44 +0000</pubDate>
		<guid>http://stephan.reposita.org/archives/2007/11/05/explicit-static-types-are-not-for-the-compiler-but-for-the-developer-duh/#comment-37415</guid>
		<description>"Beside the fact that my IDE does the typing with auto completion"

Having completion doesn't make the extra code worth having, it just reduces the number of finger presses to make it appear.

"When not working with the code for some time or another developer taking over - then is where the problem rises it’s head."

The same IDE-using developer is certainly able to glance at the original method to see what types it has, and maybe just hover over the variable declaration to see what type the inference has given it.

"def person = Factory.getPerson()
Is person of class Person? Or perhaps Student or Employee? I’m wading through legacy code and the first thing that gets out is correct naming."

person is a fairly meaningless variable name.  You're actually duplicating the type in the name, when you probably would be better off picking a better name, or getting rid of the name.  Any time you rename a class, even in Java, you can end up with this kind of variable name becoming out of sync (IDEs can help in simple cases).

"remove unneeded (cast)s where I declared the type explicitly"

Where do you need such a cast?  I'd guess most of those are misuse or lack of use of generics.

"Nameable nameable = new Person();  
printName( nameable );
Can I do this with type inference?"

Yes.  There's no logic that says that type inference must always pick the most concrete type.  However, as there's no difference in functionality in your above code between you using Nameable or Person, it doesn't matter much which is picked.

About your ArrayList example in particular, ArrayList is an example of bad API, as it exposes a List implementation by name, instead of just providing a method that gives you a List (and the actual implementation would be private/anonymous).  In fact, as I've never adapted any code from using ArrayList to using some other implementation, I'd go so far as to say for that example, using ArrayList as the variable type isn't insane.

"Explicit typing is about reducing scope, knowledge and coupling"

Explicit typing increases coupling by name, simply by making you repeat names.  IDEs or other language-aware tools can give you everything that explicit typing has, but in a type-inferred environment.

The usual case in inference is that you can override the compiler's choices if you like, so languages with inference only *allow* you to elide types, they don't force you to.  A step up on the ladder.</description>
		<content:encoded><![CDATA[<p>&#8220;Beside the fact that my IDE does the typing with auto completion&#8221;</p>
<p>Having completion doesn&#8217;t make the extra code worth having, it just reduces the number of finger presses to make it appear.</p>
<p>&#8220;When not working with the code for some time or another developer taking over - then is where the problem rises it’s head.&#8221;</p>
<p>The same IDE-using developer is certainly able to glance at the original method to see what types it has, and maybe just hover over the variable declaration to see what type the inference has given it.</p>
<p>&#8220;def person = Factory.getPerson()<br />
Is person of class Person? Or perhaps Student or Employee? I’m wading through legacy code and the first thing that gets out is correct naming.&#8221;</p>
<p>person is a fairly meaningless variable name.  You&#8217;re actually duplicating the type in the name, when you probably would be better off picking a better name, or getting rid of the name.  Any time you rename a class, even in Java, you can end up with this kind of variable name becoming out of sync (IDEs can help in simple cases).</p>
<p>&#8220;remove unneeded (cast)s where I declared the type explicitly&#8221;</p>
<p>Where do you need such a cast?  I&#8217;d guess most of those are misuse or lack of use of generics.</p>
<p>&#8220;Nameable nameable = new Person();<br />
printName( nameable );<br />
Can I do this with type inference?&#8221;</p>
<p>Yes.  There&#8217;s no logic that says that type inference must always pick the most concrete type.  However, as there&#8217;s no difference in functionality in your above code between you using Nameable or Person, it doesn&#8217;t matter much which is picked.</p>
<p>About your ArrayList example in particular, ArrayList is an example of bad API, as it exposes a List implementation by name, instead of just providing a method that gives you a List (and the actual implementation would be private/anonymous).  In fact, as I&#8217;ve never adapted any code from using ArrayList to using some other implementation, I&#8217;d go so far as to say for that example, using ArrayList as the variable type isn&#8217;t insane.</p>
<p>&#8220;Explicit typing is about reducing scope, knowledge and coupling&#8221;</p>
<p>Explicit typing increases coupling by name, simply by making you repeat names.  IDEs or other language-aware tools can give you everything that explicit typing has, but in a type-inferred environment.</p>
<p>The usual case in inference is that you can override the compiler&#8217;s choices if you like, so languages with inference only *allow* you to elide types, they don&#8217;t force you to.  A step up on the ladder.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
