<?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: Is reflection unhealthy?</title>
	<atom:link href="http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/feed/" rel="self" type="application/rss+xml" />
	<link>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/</link>
	<description>How I Learned to Stop Worrying and Love Writing Software</description>
	<pubDate>Thu, 09 Sep 2010 02:09:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Simon</title>
		<link>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/comment-page-1/#comment-4449</link>
		<dc:creator>Daniel Simon</dc:creator>
		<pubDate>Sun, 01 Feb 2009 00:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://joemorrison.org/blog/?p=41#comment-4449</guid>
		<description>Since you said you wouldn't list the application, here's some things that reflection enables that are Good Things:

Dependency Injection.
Mocking frameworks.
And in a certain sense, any kind of "late binding"/plugin application at all.  As I understand it, this sort of thing required major hoop-jumping in C/C++, resulting in the unleashing of COM upon the universe.  All that is gone with reflection.</description>
		<content:encoded><![CDATA[<p>Since you said you wouldn&#8217;t list the application, here&#8217;s some things that reflection enables that are Good Things:</p>
<p>Dependency Injection.<br />
Mocking frameworks.<br />
And in a certain sense, any kind of &#8220;late binding&#8221;/plugin application at all.  As I understand it, this sort of thing required major hoop-jumping in C/C++, resulting in the unleashing of COM upon the universe.  All that is gone with reflection.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalani Thielen</title>
		<link>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/comment-page-1/#comment-4438</link>
		<dc:creator>Kalani Thielen</dc:creator>
		<pubDate>Fri, 30 Jan 2009 00:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://joemorrison.org/blog/?p=41#comment-4438</guid>
		<description>Great post Joe,

Strictly speaking, I think that anything that makes a type system unsound as a logic "subverts strong typing."  Side-effects, general recursion, and definitely serialization (aka pickling) do that.  Whether or not you can reasonably avoid it (especially given an existing project and no mandate for reorganization) is a different question, but I think that if you accept that unsoundness you've got to be honest about what you're giving up.  There's a reason that the PLT world moved on from Scheme.

You might be interested in the AliceML project's approach to type-safe pickling (http://www.ps.uni-sb.de/Papers/abstracts/hotPickles2007.html).  It got a lot of attention on lambda-the-ultimate a couple of years ago.

I think that this issue is actually very important.  There's a danger in dismissing the importance of type safety -- in fact, just calling it "type safety" I think helps to cloud the issue.  Really, it should be called "logical consistency" because (ala Hindley-Milner) that's *exactly* what it's about.  Improving type systems to support *reasoning* about things like pickling and side-effects goes to make our programs more reliable.  You know, when you build a house of cards you can blame the guy who walked by it too quickly for blowing it down, or you can do better to come up with a sound design (a design that can be evaluated before the house is built).

At the end of all of this, I think that we programmers may need to come to terms with dependently-typed programming languages.</description>
		<content:encoded><![CDATA[<p>Great post Joe,</p>
<p>Strictly speaking, I think that anything that makes a type system unsound as a logic &#8220;subverts strong typing.&#8221;  Side-effects, general recursion, and definitely serialization (aka pickling) do that.  Whether or not you can reasonably avoid it (especially given an existing project and no mandate for reorganization) is a different question, but I think that if you accept that unsoundness you&#8217;ve got to be honest about what you&#8217;re giving up.  There&#8217;s a reason that the PLT world moved on from Scheme.</p>
<p>You might be interested in the AliceML project&#8217;s approach to type-safe pickling (http://www.ps.uni-sb.de/Papers/abstracts/hotPickles2007.html).  It got a lot of attention on lambda-the-ultimate a couple of years ago.</p>
<p>I think that this issue is actually very important.  There&#8217;s a danger in dismissing the importance of type safety &#8212; in fact, just calling it &#8220;type safety&#8221; I think helps to cloud the issue.  Really, it should be called &#8220;logical consistency&#8221; because (ala Hindley-Milner) that&#8217;s *exactly* what it&#8217;s about.  Improving type systems to support *reasoning* about things like pickling and side-effects goes to make our programs more reliable.  You know, when you build a house of cards you can blame the guy who walked by it too quickly for blowing it down, or you can do better to come up with a sound design (a design that can be evaluated before the house is built).</p>
<p>At the end of all of this, I think that we programmers may need to come to terms with dependently-typed programming languages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc Jacobs</title>
		<link>http://joemorrison.org/blog/2009/01/28/is-reflection-unhealthy/comment-page-1/#comment-4436</link>
		<dc:creator>Marc Jacobs</dc:creator>
		<pubDate>Thu, 29 Jan 2009 17:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://joemorrison.org/blog/?p=41#comment-4436</guid>
		<description>The dangers of reflection, as with any other powerful tool (such as firearms, knowledge, or hot sauce), are more fully ascribed to its user than to its usage. While reflection can (and occasionally is) misused, it isn't inherently "unhealthy". 

Reflection enables (as you point out) many meta-applications not possible with any other mechanism (short of source code analysis or de-compilation). For example, one can programmatically create class diagrams, code complexity metrics, and more via reflection.

For attributes, in particular, reflection is a logical imperative. Since attributes are simply metadata (that is, at runtime the attributes themselves have no behavior), reflection is the only mechanism by which one can create runtime behavior from attributes. Reflection is the examination of metadata. This isn't dirty or perverse. It is a decent separation of concerns.

What is dirty and perverse is your example of bad reflection usage. This is inarguably bad in most cases, hearkening back to IDispatch and late binding behavior in Visual Basic. The Invoke method on MethodInfo is clearly present for completeness, but I'm hard-pressed to imagine a good use for it in most code (as with other impure features of reflection such as SetProperty). 

But, just as F# isn't a bad functional language because it supports impure function calls, reflection isn't a bad language feature because it supports impure behavior. On occasion, impure usage of reflection will raise its hackish head, but generally reflection's pure usages will support elegant possibilities. 

As the saying goes, "Reflection doesn't subvert strong typing; people do."</description>
		<content:encoded><![CDATA[<p>The dangers of reflection, as with any other powerful tool (such as firearms, knowledge, or hot sauce), are more fully ascribed to its user than to its usage. While reflection can (and occasionally is) misused, it isn&#8217;t inherently &#8220;unhealthy&#8221;. </p>
<p>Reflection enables (as you point out) many meta-applications not possible with any other mechanism (short of source code analysis or de-compilation). For example, one can programmatically create class diagrams, code complexity metrics, and more via reflection.</p>
<p>For attributes, in particular, reflection is a logical imperative. Since attributes are simply metadata (that is, at runtime the attributes themselves have no behavior), reflection is the only mechanism by which one can create runtime behavior from attributes. Reflection is the examination of metadata. This isn&#8217;t dirty or perverse. It is a decent separation of concerns.</p>
<p>What is dirty and perverse is your example of bad reflection usage. This is inarguably bad in most cases, hearkening back to IDispatch and late binding behavior in Visual Basic. The Invoke method on MethodInfo is clearly present for completeness, but I&#8217;m hard-pressed to imagine a good use for it in most code (as with other impure features of reflection such as SetProperty). </p>
<p>But, just as F# isn&#8217;t a bad functional language because it supports impure function calls, reflection isn&#8217;t a bad language feature because it supports impure behavior. On occasion, impure usage of reflection will raise its hackish head, but generally reflection&#8217;s pure usages will support elegant possibilities. </p>
<p>As the saying goes, &#8220;Reflection doesn&#8217;t subvert strong typing; people do.&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
