<?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 Scala Not &#8220;Functional Enough&#8221;?</title>
	<atom:link href="http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Sun, 29 Aug 2010 20:01:44 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4961</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 14 Apr 2010 20:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4961</guid>
		<description>James- I think you can indeed write a Haskell program that behaves differently depending on whether or not an expression has been evaluated. This is a problem with hGetContents: its behavior depends on whether the result is evaluated before or after the corresponding file handle is closed. So

printsAll :: FilePath -&gt; IO String
printsAll f = do
  h 
will print the entire contents of a file, but

printsNothing :: FilePath -&gt; IO String
printsNothing f = do
  h 
doesn&#039;t print anything. This is entirely because of an interaction between Haskell&#039;s non-strict semantics and evaluation order. I think if you force evaluation of s using deepSeq before closing the file, it does print the contents.</description>
		<content:encoded><![CDATA[<p>James- I think you can indeed write a Haskell program that behaves differently depending on whether or not an expression has been evaluated. This is a problem with hGetContents: its behavior depends on whether the result is evaluated before or after the corresponding file handle is closed. So</p>
<p>printsAll :: FilePath -&gt; IO String<br />
printsAll f = do<br />
  h<br />
will print the entire contents of a file, but</p>
<p>printsNothing :: FilePath -&gt; IO String<br />
printsNothing f = do<br />
  h<br />
doesn&#8217;t print anything. This is entirely because of an interaction between Haskell&#8217;s non-strict semantics and evaluation order. I think if you force evaluation of s using deepSeq before closing the file, it does print the contents.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4926</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Fri, 22 Jan 2010 17:43:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4926</guid>
		<description>ArtemGr, Haskell&#039;s non-strict semantics are not a source of impurity. Barring unsafePerformIO* and friends (which is a source of impurity) and divergence (which is arguably a source of impurity, depending on how you look at it) you cannot write  a Haskell program that behaves differently depending on whether an expression has been evaluated or not.</description>
		<content:encoded><![CDATA[<p>ArtemGr, Haskell&#8217;s non-strict semantics are not a source of impurity. Barring unsafePerformIO* and friends (which is a source of impurity) and divergence (which is arguably a source of impurity, depending on how you look at it) you cannot write  a Haskell program that behaves differently depending on whether an expression has been evaluated or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ArtemGr</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4925</link>
		<dc:creator>ArtemGr</dc:creator>
		<pubDate>Fri, 22 Jan 2010 13:42:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4925</guid>
		<description>From a practical perspective, Haskell isn&#039;t a functional language: lazy evaluation (thunks) produces undesired side-effects. Every value in a standard Haskell is a *mutable* thunk.</description>
		<content:encoded><![CDATA[<p>From a practical perspective, Haskell isn&#8217;t a functional language: lazy evaluation (thunks) produces undesired side-effects. Every value in a standard Haskell is a *mutable* thunk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4353</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Fri, 28 Nov 2008 17:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4353</guid>
		<description>Okay, I see.  We&#039;re talking about two different things.  Let me amend.  Ultra-fine grained transactions as shown in the rcar, rcdr, rset-car! and rset-cdr! examples are useless if that&#039;s all you&#039;re using - the system becomes in effect transactionless.  But, as you point out, if you use more reasonable transaction granularity as well as the ultra-fine stuff then there is some utility.</description>
		<content:encoded><![CDATA[<p>Okay, I see.  We&#8217;re talking about two different things.  Let me amend.  Ultra-fine grained transactions as shown in the rcar, rcdr, rset-car! and rset-cdr! examples are useless if that&#8217;s all you&#8217;re using &#8211; the system becomes in effect transactionless.  But, as you point out, if you use more reasonable transaction granularity as well as the ultra-fine stuff then there is some utility.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Hickey</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4352</link>
		<dc:creator>Rich Hickey</dc:creator>
		<pubDate>Fri, 28 Nov 2008 15:50:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4352</guid>
		<description>@James

I understand the atomic consistency of references. The value isn&#039;t for the threads doing the fine-grained reads and writes, it&#039;s for the concurrent coarser-grained transactions manipulating those same refs, which are able to see a snapshot of the world for their duration strictly because the fine-grained activity also participates in the transaction system.

Obviously, unconditional atomic overwrites of shared refs have limited utility in a concurrent program, but the above guarantee matters, especially when additional concurrent use is added later, as it so often is.</description>
		<content:encoded><![CDATA[<p>@James</p>
<p>I understand the atomic consistency of references. The value isn&#8217;t for the threads doing the fine-grained reads and writes, it&#8217;s for the concurrent coarser-grained transactions manipulating those same refs, which are able to see a snapshot of the world for their duration strictly because the fine-grained activity also participates in the transaction system.</p>
<p>Obviously, unconditional atomic overwrites of shared refs have limited utility in a concurrent program, but the above guarantee matters, especially when additional concurrent use is added later, as it so often is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4351</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Fri, 28 Nov 2008 14:56:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4351</guid>
		<description>Rich, I get the point you&#039;re making about wrapping in a larger transaction.  Fair enough.  

But I don&#039;t see the point you&#039;re making about the utility of transactionally protecting a single read or single write to a ref as compared to not using transactions at all.  The JVM already guarantees atomicity of reads and writes to references.   

I could write the following in Java

class Ref[T] {
   private T x;
   public Ref(T x) {this.x = x;}
   def get {return x;}
   def set(T newX){x = newX;}
}

If multiple threads bang against one instance of this I should get the same guarantee as multiple threads doing ultra-fine grained transactions in Clojure.  The pointer would never be corrupted, but a thread that does two quick reads in succession or a write and then an immediate read would have no promise of seeing the same value twice.

That&#039;s not to bash Clojure or STM in general.  It&#039;s just the nature of transactions: they only give you as much consistency as you allow them to.</description>
		<content:encoded><![CDATA[<p>Rich, I get the point you&#8217;re making about wrapping in a larger transaction.  Fair enough.  </p>
<p>But I don&#8217;t see the point you&#8217;re making about the utility of transactionally protecting a single read or single write to a ref as compared to not using transactions at all.  The JVM already guarantees atomicity of reads and writes to references.   </p>
<p>I could write the following in Java</p>
<p>class Ref[T] {<br />
   private T x;<br />
   public Ref(T x) {this.x = x;}<br />
   def get {return x;}<br />
   def set(T newX){x = newX;}<br />
}</p>
<p>If multiple threads bang against one instance of this I should get the same guarantee as multiple threads doing ultra-fine grained transactions in Clojure.  The pointer would never be corrupted, but a thread that does two quick reads in succession or a write and then an immediate read would have no promise of seeing the same value twice.</p>
<p>That&#8217;s not to bash Clojure or STM in general.  It&#8217;s just the nature of transactions: they only give you as much consistency as you allow them to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Hickey</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4350</link>
		<dc:creator>Rich Hickey</dc:creator>
		<pubDate>Fri, 28 Nov 2008 14:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4350</guid>
		<description>@James

I found this thread only recently, so sorry to chime in late.

&gt;The fact that it’s “transactional” is invisible to the client code and in fact rather useless as each transaction protects only a single mutable reference.

The &#039;transactionality&#039; of these atomic functions is not useless at all. If some other thread were using the same ref x, it could make transactional read-modify-write decisions without being corrupted by the actions of these functions. Also, while it&#039;s not idiomatic to write such fine grained transactions, a set of calls to these functions could be placed in an enclosing transaction and would join it, thus allowing the composition of more coarse-grained transactions.</description>
		<content:encoded><![CDATA[<p>@James</p>
<p>I found this thread only recently, so sorry to chime in late.</p>
<p>&gt;The fact that it’s “transactional” is invisible to the client code and in fact rather useless as each transaction protects only a single mutable reference.</p>
<p>The &#8216;transactionality&#8217; of these atomic functions is not useless at all. If some other thread were using the same ref x, it could make transactional read-modify-write decisions without being corrupted by the actions of these functions. Also, while it&#8217;s not idiomatic to write such fine grained transactions, a set of calls to these functions could be placed in an enclosing transaction and would join it, thus allowing the composition of more coarse-grained transactions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaNovice</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4201</link>
		<dc:creator>JavaNovice</dc:creator>
		<pubDate>Wed, 22 Oct 2008 16:13:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4201</guid>
		<description>*LOL*
Sorry i couldn&#039;t resist but the last comment seemed subtly funny to me and also reminds me on the cobol code i have to read from time to time...</description>
		<content:encoded><![CDATA[<p>*LOL*<br />
Sorry i couldn&#8217;t resist but the last comment seemed subtly funny to me and also reminds me on the cobol code i have to read from time to time&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4196</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Tue, 21 Oct 2008 23:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4196</guid>
		<description>Good point! Re-entrancy is for academics, real programmers use global variables.</description>
		<content:encoded><![CDATA[<p>Good point! Re-entrancy is for academics, real programmers use global variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David R. MacIver</title>
		<link>http://www.codecommit.com/blog/scala/is-scala-not-functional-enough/comment-page-1#comment-4194</link>
		<dc:creator>David R. MacIver</dc:creator>
		<pubDate>Tue, 21 Oct 2008 20:36:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#comment-4194</guid>
		<description>James:

Of course you can define such a thing. 

static funcPtr theFirstFunction;
static funcPtr theSecondFunction;

int theComposedFunction(int x){
  return theFirstFunction(theSecondFunction(x))
}

funcPtr compose (funcPtr f, funcPtr g) {
   theFirstFunction = f
   theSecondFunction = g
  return *theComposedFunction
}

(Or something like that. I always forget the details of C)

What do you mean &quot;re-entrant&quot;?</description>
		<content:encoded><![CDATA[<p>James:</p>
<p>Of course you can define such a thing. </p>
<p>static funcPtr theFirstFunction;<br />
static funcPtr theSecondFunction;</p>
<p>int theComposedFunction(int x){<br />
  return theFirstFunction(theSecondFunction(x))<br />
}</p>
<p>funcPtr compose (funcPtr f, funcPtr g) {<br />
   theFirstFunction = f<br />
   theSecondFunction = g<br />
  return *theComposedFunction<br />
}</p>
<p>(Or something like that. I always forget the details of C)</p>
<p>What do you mean &#8220;re-entrant&#8221;?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
