<?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: So Begins the Functional Revolution</title>
	<atom:link href="http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:21:24 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Channing Walton</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3646</link>
		<dc:creator>Channing Walton</dc:creator>
		<pubDate>Fri, 23 May 2008 20:28:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3646</guid>
		<description>All the business problems I have worked on in the finance industry over the last 8 years would have been much much simpler had we been using a language like scala that blends functional and OO concepts. The apps I&#039;ve worked on all required complex aggregation, sorting, filtering, rules, etc., on complex models. In desperation we ended up writing a library in Java to help us (http://jedi.codehaus.org/).

Languages like scala are ideal for business applications in my experience at least. Unfortunately, I cannot show you these real world business examples :-)</description>
		<content:encoded><![CDATA[<p>All the business problems I have worked on in the finance industry over the last 8 years would have been much much simpler had we been using a language like scala that blends functional and OO concepts. The apps I&#8217;ve worked on all required complex aggregation, sorting, filtering, rules, etc., on complex models. In desperation we ended up writing a library in Java to help us (<a href="http://jedi.codehaus.org/" rel="nofollow">http://jedi.codehaus.org/</a>).</p>
<p>Languages like scala are ideal for business applications in my experience at least. Unfortunately, I cannot show you these real world business examples <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3643</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Fri, 23 May 2008 01:10:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3643</guid>
		<description>Stephan,

Same old tired stuff.  &quot;Your example code doesn&#039;t solve my business problem so it&#039;s worthless.&quot;

&gt;I find it rather amusing that most functional examples are not about a business domain but about … functions. And people deduce from there that functional languages are better suited to express functions. Doh! Who would have guessed.

What business domain does not have lists and sets of things?  What business never needs to search, sort, sum, fold, spindle, and mutilate those collections?  If nothing else functional programming already brings a nice win for this important bit.  But hey, if most of your business domain is better modeled with OO style objects and imperative code, no problem - Common Lisp, OCaml, and Scala can do that too.</description>
		<content:encoded><![CDATA[<p>Stephan,</p>
<p>Same old tired stuff.  &#8220;Your example code doesn&#8217;t solve my business problem so it&#8217;s worthless.&#8221;</p>
<p>&gt;I find it rather amusing that most functional examples are not about a business domain but about … functions. And people deduce from there that functional languages are better suited to express functions. Doh! Who would have guessed.</p>
<p>What business domain does not have lists and sets of things?  What business never needs to search, sort, sum, fold, spindle, and mutilate those collections?  If nothing else functional programming already brings a nice win for this important bit.  But hey, if most of your business domain is better modeled with OO style objects and imperative code, no problem &#8211; Common Lisp, OCaml, and Scala can do that too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Iry</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3642</link>
		<dc:creator>James Iry</dc:creator>
		<pubDate>Fri, 23 May 2008 00:48:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3642</guid>
		<description>Brendan, you make several errors in your post

&gt;Functional programming is not additive, it is subtractive. It removes operations ,

In the impure sense of the word functional it&#039;s additive.  It adds functional composition, closures, etc.  You mention ML, lisp, and Scala in your post - all of these languages allow mutable state and IO side effects.  Scala in particular makes it just as trivially easy to do as Java.  Some lisps do, too.

&gt;IHowever, invariably the C implementation is real quicksort, whereas the fp implementation is *mergesort*

Factually incorrect.   The functional sort you are seeing is the non-in place form of quicksort.  It has the same time complexity as in-place quicksort - O(n^2) worst case - but a different space complexity.  Mergesort, on the other hand, has the better worst case time complexity - O(n log n).  And, believe it or not, there&#039;s an imperative form of mergesort on linked lists with O(1) additional space complexity.

&gt; Also, while quicksort is not *asymptotically* worse than mergesort

Absolutely it is asymptotically worse.  See above about O(n^2) vs O(n log n).  Quicksort has many advantages, though, so for most reasonably sized, somewhat randomly ordered data sets in mutable arrays, quicksort is in practice faster.  But I will say this again, if you are about asymptotic time analysis then quicksort is worse.

&gt;Really the nice things about scala, ml, lisp, etc are features that can and probably *will* be implemented in more mainstream languages. 

How &#039;bout a general expression orientation as opposed to a statement orientation?   Why do we need both &quot;if&quot; and the ternary operator in all the C offspring?  Will that kind of thinking come in a mainstream language?  Yup - when a mainstream language is functional (even if impurely so).

&gt; C already has always had first class functions.

C&#039;s functions are not first class unless by &quot;first class&quot; you mean &quot;distinctly second class.&quot;  Function pointers mean that top-level functions can be treated as values, true, but, unlike truly first class types of values like integers, you cannot create a new C function at runtime by say combining two other functions.

&gt; What makes a FP language an FP language is that it makes writing procedural code either impossible, or in the case of an *impure* functional language, just really difficult,

Not so.  Where is it written that an impure functional language must make its imperative side more difficult?  A functional language does make writing side effect free code easy - but that doesn&#039;t mean side effecting code need be any harder.  Again, check out Scala.  The syntax for doing side effecting stuff is pretty similar to Java&#039;s - e.g incrementing x by 100 is just &quot;x = x + 100&quot; or even &quot;x += 100&quot;.  

Also, imperative programming languages only have native support for one kind of side effect (destructively changing the state of the world) whereas a bit of monadic sugar allows a language like Scala or Haskell to cleanly deal with things that a imperative programmer wouldn&#039;t even understand as side effects.  But that&#039;s a discussion for another time and place.</description>
		<content:encoded><![CDATA[<p>Brendan, you make several errors in your post</p>
<p>&gt;Functional programming is not additive, it is subtractive. It removes operations ,</p>
<p>In the impure sense of the word functional it&#8217;s additive.  It adds functional composition, closures, etc.  You mention ML, lisp, and Scala in your post &#8211; all of these languages allow mutable state and IO side effects.  Scala in particular makes it just as trivially easy to do as Java.  Some lisps do, too.</p>
<p>&gt;IHowever, invariably the C implementation is real quicksort, whereas the fp implementation is *mergesort*</p>
<p>Factually incorrect.   The functional sort you are seeing is the non-in place form of quicksort.  It has the same time complexity as in-place quicksort &#8211; O(n^2) worst case &#8211; but a different space complexity.  Mergesort, on the other hand, has the better worst case time complexity &#8211; O(n log n).  And, believe it or not, there&#8217;s an imperative form of mergesort on linked lists with O(1) additional space complexity.</p>
<p>&gt; Also, while quicksort is not *asymptotically* worse than mergesort</p>
<p>Absolutely it is asymptotically worse.  See above about O(n^2) vs O(n log n).  Quicksort has many advantages, though, so for most reasonably sized, somewhat randomly ordered data sets in mutable arrays, quicksort is in practice faster.  But I will say this again, if you are about asymptotic time analysis then quicksort is worse.</p>
<p>&gt;Really the nice things about scala, ml, lisp, etc are features that can and probably *will* be implemented in more mainstream languages. </p>
<p>How &#8217;bout a general expression orientation as opposed to a statement orientation?   Why do we need both &#8220;if&#8221; and the ternary operator in all the C offspring?  Will that kind of thinking come in a mainstream language?  Yup &#8211; when a mainstream language is functional (even if impurely so).</p>
<p>&gt; C already has always had first class functions.</p>
<p>C&#8217;s functions are not first class unless by &#8220;first class&#8221; you mean &#8220;distinctly second class.&#8221;  Function pointers mean that top-level functions can be treated as values, true, but, unlike truly first class types of values like integers, you cannot create a new C function at runtime by say combining two other functions.</p>
<p>&gt; What makes a FP language an FP language is that it makes writing procedural code either impossible, or in the case of an *impure* functional language, just really difficult,</p>
<p>Not so.  Where is it written that an impure functional language must make its imperative side more difficult?  A functional language does make writing side effect free code easy &#8211; but that doesn&#8217;t mean side effecting code need be any harder.  Again, check out Scala.  The syntax for doing side effecting stuff is pretty similar to Java&#8217;s &#8211; e.g incrementing x by 100 is just &#8220;x = x + 100&#8243; or even &#8220;x += 100&#8243;.  </p>
<p>Also, imperative programming languages only have native support for one kind of side effect (destructively changing the state of the world) whereas a bit of monadic sugar allows a language like Scala or Haskell to cleanly deal with things that a imperative programmer wouldn&#8217;t even understand as side effects.  But that&#8217;s a discussion for another time and place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asd</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3639</link>
		<dc:creator>Asd</dc:creator>
		<pubDate>Thu, 22 May 2008 12:27:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3639</guid>
		<description>You can also use
println(args.projection.map(_.toInt).foldLeft(0)(_ + _))

This will not create the intermediate array, but will calculate the mapped element when needed (if I understand it correctly). Of course there are tradeoffs for both versions.</description>
		<content:encoded><![CDATA[<p>You can also use<br />
println(args.projection.map(_.toInt).foldLeft(0)(_ + _))</p>
<p>This will not create the intermediate array, but will calculate the mapped element when needed (if I understand it correctly). Of course there are tradeoffs for both versions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Shaw</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3628</link>
		<dc:creator>Steven Shaw</dc:creator>
		<pubDate>Wed, 21 May 2008 17:12:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3628</guid>
		<description>Of course! Thanks :)</description>
		<content:encoded><![CDATA[<p>Of course! Thanks <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3627</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Wed, 21 May 2008 16:53:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3627</guid>
		<description>No need for laziness, this works just as well:

println(”sum = ” + args.foldLeft(0)(_ + _.toInt))

It is a lot more concise, and I thought about doing it this way, but I wanted to use the map(...) function, something which has taken almost as much flack as fold.</description>
		<content:encoded><![CDATA[<p>No need for laziness, this works just as well:</p>
<p>println(”sum = ” + args.foldLeft(0)(_ + _.toInt))</p>
<p>It is a lot more concise, and I thought about doing it this way, but I wanted to use the map(&#8230;) function, something which has taken almost as much flack as fold.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Shaw</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3626</link>
		<dc:creator>Steven Shaw</dc:creator>
		<pubDate>Wed, 21 May 2008 16:51:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3626</guid>
		<description>The Scala code for summing the argument first constructs an array of ints which the typical equivalent Java code does not.

You could do:

  println(&quot;sum = &quot; + args.foldLeft(0)(_.toInt + _.toInt))

Is there a way to lazily map the toInt over the array to prevent repeating the call to toInt above?</description>
		<content:encoded><![CDATA[<p>The Scala code for summing the argument first constructs an array of ints which the typical equivalent Java code does not.</p>
<p>You could do:</p>
<p>  println(&#8220;sum = &#8221; + args.foldLeft(0)(_.toInt + _.toInt))</p>
<p>Is there a way to lazily map the toInt over the array to prevent repeating the call to toInt above?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Miller</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3618</link>
		<dc:creator>Brendan Miller</dc:creator>
		<pubDate>Tue, 20 May 2008 09:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3618</guid>
		<description>Various cool features developed in academic languages like ML and lisp have made it into mainstream languages, but it&#039;s pretty unlikely that a functional language will ever make it mainstream, and here&#039;s why

Functional programming is not additive, it is subtractive. It removes operations , i.e. operations with side effects. In practice all nontrivial programs really *do* need side effects and *very often* this means that almost all functional languages aren&#039;t *really* functional languages, they just make manipulating state more *annoying*, not impossible.

In a real functional language, you *could not* implement a quick sort. I&#039;ve seen quite a few FP advocates claim to write quicksort, and compare it to a C implementation of quicksort. However, invariably the C implementation is real quicksort, whereas the fp implementation is *mergesort*. Quicksort requires a mutable vector to get its performance boost. I would *assume* that everyone can tell the difference between two totally different sorting algorithms with different complexity, but the examples stay out there for some reason anyway...

Also, while quicksort is not *asymptotically* worse than mergesort (quite the opposite, just quicker for the common in memory and cache case), there are plenty of algorithms where a pure functional implementation is necessarily some higher order polynomial running time than the case possible with mutable state (think dynamic programming). I think everyone can agree that&#039;s the sort of performance decrease that isn&#039;t acceptable just to get a nicer looking language.

Really the nice things about scala, ml, lisp, etc are features that can and probably *will* be implemented in more mainstream languages. C already has always had first class functions. Closures are planned for c++ sometime in 2009. However, those things are not functional programming. What makes a FP language an FP language is that it makes writing procedural code either impossible, or in the case of an *impure* functional language, just really difficult, like how Ocaml supports procedural and OO programming, but makes the syntax ugly intentionally.</description>
		<content:encoded><![CDATA[<p>Various cool features developed in academic languages like ML and lisp have made it into mainstream languages, but it&#8217;s pretty unlikely that a functional language will ever make it mainstream, and here&#8217;s why</p>
<p>Functional programming is not additive, it is subtractive. It removes operations , i.e. operations with side effects. In practice all nontrivial programs really *do* need side effects and *very often* this means that almost all functional languages aren&#8217;t *really* functional languages, they just make manipulating state more *annoying*, not impossible.</p>
<p>In a real functional language, you *could not* implement a quick sort. I&#8217;ve seen quite a few FP advocates claim to write quicksort, and compare it to a C implementation of quicksort. However, invariably the C implementation is real quicksort, whereas the fp implementation is *mergesort*. Quicksort requires a mutable vector to get its performance boost. I would *assume* that everyone can tell the difference between two totally different sorting algorithms with different complexity, but the examples stay out there for some reason anyway&#8230;</p>
<p>Also, while quicksort is not *asymptotically* worse than mergesort (quite the opposite, just quicker for the common in memory and cache case), there are plenty of algorithms where a pure functional implementation is necessarily some higher order polynomial running time than the case possible with mutable state (think dynamic programming). I think everyone can agree that&#8217;s the sort of performance decrease that isn&#8217;t acceptable just to get a nicer looking language.</p>
<p>Really the nice things about scala, ml, lisp, etc are features that can and probably *will* be implemented in more mainstream languages. C already has always had first class functions. Closures are planned for c++ sometime in 2009. However, those things are not functional programming. What makes a FP language an FP language is that it makes writing procedural code either impossible, or in the case of an *impure* functional language, just really difficult, like how Ocaml supports procedural and OO programming, but makes the syntax ugly intentionally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Jackman</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3617</link>
		<dc:creator>Ben Jackman</dc:creator>
		<pubDate>Tue, 20 May 2008 06:51:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3617</guid>
		<description>Hi Daniel,

I recently started learning Scala to and have started my first project with it, a visual interpreter that uses a Swing based interface instead of the command line (http://code.google.com/p/scalide/). I agree with what you are saying when I first started I would use a lot of while and for loops. Now I find myself thinking about how to write a combination of calls to filter / map /  fold etc... and find them easier to read than imperative loops in several cases. 

The pattern matching, actors library, type inference, and drive to keep data immutable are really nice too.

Ben</description>
		<content:encoded><![CDATA[<p>Hi Daniel,</p>
<p>I recently started learning Scala to and have started my first project with it, a visual interpreter that uses a Swing based interface instead of the command line (<a href="http://code.google.com/p/scalide/" rel="nofollow">http://code.google.com/p/scalide/</a>). I agree with what you are saying when I first started I would use a lot of while and for loops. Now I find myself thinking about how to write a combination of calls to filter / map /  fold etc&#8230; and find them easier to read than imperative loops in several cases. </p>
<p>The pattern matching, actors library, type inference, and drive to keep data immutable are really nice too.</p>
<p>Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Rogers</title>
		<link>http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution/comment-page-1#comment-3616</link>
		<dc:creator>Paul Rogers</dc:creator>
		<pubDate>Tue, 20 May 2008 05:41:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/so-begins-the-functional-revolution#comment-3616</guid>
		<description>@Stephan

Google is in the business domain, they produced MapReduce for a real business problem, and they are now reaping huge benefit. MapReduce *is* functional thinking. The issue isn&#039;t whether an imperative or functional implementation of quicksort is better; it&#039;s whether you can employ critical thinking to help solve real problems. I enjoy learning and thinking in different programming paradigms. The best way to think outside the box is to never climb in.

Paul</description>
		<content:encoded><![CDATA[<p>@Stephan</p>
<p>Google is in the business domain, they produced MapReduce for a real business problem, and they are now reaping huge benefit. MapReduce *is* functional thinking. The issue isn&#8217;t whether an imperative or functional implementation of quicksort is better; it&#8217;s whether you can employ critical thinking to help solve real problems. I enjoy learning and thinking in different programming paradigms. The best way to think outside the box is to never climb in.</p>
<p>Paul</p>
]]></content:encoded>
	</item>
</channel>
</rss>

