<?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: Why Functional Programming in Java is Dangerous</title>
	<atom:link href="http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/</link>
	<description>Longer than a blog; shorter than a book</description>
	<lastBuildDate>Wed, 22 May 2013 10:09:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: EricH</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1502914</link>
		<dc:creator>EricH</dc:creator>
		<pubDate>Sat, 04 May 2013 06:01:30 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1502914</guid>
		<description><![CDATA[Clojure, Scala, Haskell, et al, would all also crap out if you write code that forces them to store all positive integers in a list. That&#039;s not what they&#039;re doing. The example you cite uses method which creates a list of numbers in a range. Being lazy has nothing to do with it. You could extract the list to a concrete immutable and be fine. You create a list of all integers, and then (would without OOM exception) *use* the first 25 of them. Functional is a style. Java can be used to write purely functional code... it&#039;s just painfully verbose.

Guava is one such library that adds a number of functional pattern support, including lazy evaluation of transformations of collections. With a bit of finagling, one could implement them from scratch though. (for some reason the forum is eating my indents...)

&lt;code&gt;
public List nameList(List people) {
	return Lists.transform(people, new Function() {
		public String apply(Person person) {
			return person.getName();
		}
	});
}&lt;/code&gt;

Whereas e.g. scala has a lot of support for functional idioms, largely due to first class functions and convenient shorthand:

&lt;code&gt;
def nameList(people: List[Person]) = people.map(_.name)&lt;/code&gt;

Same method, less headaches. :)

As for why the java std lib doesn&#039;t have a Range class, I have no idea. This is a simple way to create one:

http://stackoverflow.com/a/6828887/1057157]]></description>
		<content:encoded><![CDATA[<p>Clojure, Scala, Haskell, et al, would all also crap out if you write code that forces them to store all positive integers in a list. That&#8217;s not what they&#8217;re doing. The example you cite uses method which creates a list of numbers in a range. Being lazy has nothing to do with it. You could extract the list to a concrete immutable and be fine. You create a list of all integers, and then (would without OOM exception) *use* the first 25 of them. Functional is a style. Java can be used to write purely functional code&#8230; it&#8217;s just painfully verbose.</p>
<p>Guava is one such library that adds a number of functional pattern support, including lazy evaluation of transformations of collections. With a bit of finagling, one could implement them from scratch though. (for some reason the forum is eating my indents&#8230;)</p>
<p><code><br />
public List nameList(List people) {<br />
	return Lists.transform(people, new Function() {<br />
		public String apply(Person person) {<br />
			return person.getName();<br />
		}<br />
	});<br />
}</code></p>
<p>Whereas e.g. scala has a lot of support for functional idioms, largely due to first class functions and convenient shorthand:</p>
<p><code><br />
def nameList(people: List[Person]) = people.map(_.name)</code></p>
<p>Same method, less headaches. <img src='http://cafe.elharo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As for why the java std lib doesn&#8217;t have a Range class, I have no idea. This is a simple way to create one:</p>
<p><a href="http://stackoverflow.com/a/6828887/1057157" rel="nofollow">http://stackoverflow.com/a/6828887/1057157</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Semiografo</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1471263</link>
		<dc:creator>Semiografo</dc:creator>
		<pubDate>Sun, 07 Apr 2013 02:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1471263</guid>
		<description><![CDATA[I wonder why functional programming is considered more elegant than other paradigms. The right question is: more elegant where? For traversing graphs? For japanese people or anyone else who read from right to the left? 

Sometimes I think functional programmers are pleased by the fact that only them can understand their code. Functional code produce much less source code than procedural&#039;s for doing some complex scientific algorithm. In fact, functional code almost mimics mathematical notation. On the other hand, procedural is more algorithmic in the sense that you can organize your solution as an ordered sequence of tasks - and not a reverse order or a fixed-point trick making every stuff anonymous (the fewer the identifiers the better for functionalists). 

That said, I love Javascript, the convergence between the functional and procedural worlds. You can do anonymous recursions with something like a Y combinator or even making something more legible like encapsulating named recursive functions inside another (outer) function which holds static parameters in relation to the inner function.]]></description>
		<content:encoded><![CDATA[<p>I wonder why functional programming is considered more elegant than other paradigms. The right question is: more elegant where? For traversing graphs? For japanese people or anyone else who read from right to the left? </p>
<p>Sometimes I think functional programmers are pleased by the fact that only them can understand their code. Functional code produce much less source code than procedural&#8217;s for doing some complex scientific algorithm. In fact, functional code almost mimics mathematical notation. On the other hand, procedural is more algorithmic in the sense that you can organize your solution as an ordered sequence of tasks &#8211; and not a reverse order or a fixed-point trick making every stuff anonymous (the fewer the identifiers the better for functionalists). </p>
<p>That said, I love Javascript, the convergence between the functional and procedural worlds. You can do anonymous recursions with something like a Y combinator or even making something more legible like encapsulating named recursive functions inside another (outer) function which holds static parameters in relation to the inner function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FFFFFF</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1446258</link>
		<dc:creator>FFFFFF</dc:creator>
		<pubDate>Tue, 12 Mar 2013 04:01:21 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1446258</guid>
		<description><![CDATA[&quot;Functional idioms in Java are performance bugs waiting to bite you. &quot;

Nope.

- You can always compromise and use loops instead of tail recursion, and still have mostly &quot;functional&quot; java code. If you do this there is no &quot;performance bugs&quot;
- Functional Java (http://functionaljava.org/) has no problem with recursion
- If you actually need recursion (i.e. the function cannot be written tail-recursively) the most natural way is to use the stack instead of making an explicit stack. Turn up the stack size.]]></description>
		<content:encoded><![CDATA[<p>&#8220;Functional idioms in Java are performance bugs waiting to bite you. &#8221;</p>
<p>Nope.</p>
<p>- You can always compromise and use loops instead of tail recursion, and still have mostly &#8220;functional&#8221; java code. If you do this there is no &#8220;performance bugs&#8221;<br />
- Functional Java (<a href="http://functionaljava.org/" rel="nofollow">http://functionaljava.org/</a>) has no problem with recursion<br />
- If you actually need recursion (i.e. the function cannot be written tail-recursively) the most natural way is to use the stack instead of making an explicit stack. Turn up the stack size.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diego</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1434824</link>
		<dc:creator>diego</dc:creator>
		<pubDate>Fri, 01 Mar 2013 14:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1434824</guid>
		<description><![CDATA[Venkat Subramaniam solution -&gt; http://blog.agiledeveloper.com/2013/01/functional-programming-in-java-is-quite.html]]></description>
		<content:encoded><![CDATA[<p>Venkat Subramaniam solution -&gt; <a href="http://blog.agiledeveloper.com/2013/01/functional-programming-in-java-is-quite.html" rel="nofollow">http://blog.agiledeveloper.com/2013/01/functional-programming-in-java-is-quite.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sequências Infinitas em Scala e Java &#171; Mente de Iniciante</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1413715</link>
		<dc:creator>Sequências Infinitas em Scala e Java &#171; Mente de Iniciante</dc:creator>
		<pubDate>Mon, 11 Feb 2013 20:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1413715</guid>
		<description><![CDATA[[...] Recentemente, o polêmico Uncle Bob tem escrito sobre como utilizar conceito de Programação Funcional em Java e tem recebido diversas críticas. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Recentemente, o polêmico Uncle Bob tem escrito sobre como utilizar conceito de Programação Funcional em Java e tem recebido diversas críticas. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MeMySelfAndI</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1384936</link>
		<dc:creator>MeMySelfAndI</dc:creator>
		<pubDate>Wed, 30 Jan 2013 15:21:14 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1384936</guid>
		<description><![CDATA[@OP: Please do not use straw-men arguments, those are ONLY reserved for people trying to push (shiny new feature) into Java.
Otherwise I agree with those writing that if you want functional programming, please go use a functional language and stop trying to screw up our Java. It is not perfect and I bet that other cool language you were using did everything sooo much better. If it was that great, why not stay with it?]]></description>
		<content:encoded><![CDATA[<p>@OP: Please do not use straw-men arguments, those are ONLY reserved for people trying to push (shiny new feature) into Java.<br />
Otherwise I agree with those writing that if you want functional programming, please go use a functional language and stop trying to screw up our Java. It is not perfect and I bet that other cool language you were using did everything sooo much better. If it was that great, why not stay with it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlok</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1381628</link>
		<dc:creator>carlok</dc:creator>
		<pubDate>Tue, 29 Jan 2013 12:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1381628</guid>
		<description><![CDATA[For F&#039;s (Frank Umberto Clark Kennedy&#039;s) sake, those saying that &quot;Java 8 will solve this&quot;: haven&#039;t you noticed the pattern ? Java 6 will fix ___, Java 7 will fix ___, Java 8 will fix ___, Java N will fix ___, Java N+1 will fix ___ .....

In the meantime, you wasted YEARS programming in (and defending) an UNFIXABLE BRAINDEAD PARODY OF A LANGUAGE/RUNTIME/ECOSYSTEM, whilst you might have saved yourselves the troubles and used a sane one.

Of what use is that JVM can be fast in microbenchmarks when you kill that advantage with layers upon layers of needles abstractions and wrappers and libraries that allow you to do ___ when this can be done in a few lines in a sane language ?

In the end a LARGE applications written in Ruby/Python/Tcl/$whatever$ can be faster then Java ones (and more flexible / maintainable) because you don&#039;t need shitloads of useless boilerplate nor tons of XML, there are no pointless hoops to jump through, just plain solution which even slower runtimes can execute faster than JVM will execute your mammoth blobs.

ALSO:

All idiots crying &quot;This is not how you would do this in Java, ... yada yada&quot;: it seems to me that this was the point of the post, which you somehow missed. But missing the point is perhaps to be expected from average [Java] code monkey.]]></description>
		<content:encoded><![CDATA[<p>For F&#8217;s (Frank Umberto Clark Kennedy&#8217;s) sake, those saying that &#8220;Java 8 will solve this&#8221;: haven&#8217;t you noticed the pattern ? Java 6 will fix ___, Java 7 will fix ___, Java 8 will fix ___, Java N will fix ___, Java N+1 will fix ___ &#8230;..</p>
<p>In the meantime, you wasted YEARS programming in (and defending) an UNFIXABLE BRAINDEAD PARODY OF A LANGUAGE/RUNTIME/ECOSYSTEM, whilst you might have saved yourselves the troubles and used a sane one.</p>
<p>Of what use is that JVM can be fast in microbenchmarks when you kill that advantage with layers upon layers of needles abstractions and wrappers and libraries that allow you to do ___ when this can be done in a few lines in a sane language ?</p>
<p>In the end a LARGE applications written in Ruby/Python/Tcl/$whatever$ can be faster then Java ones (and more flexible / maintainable) because you don&#8217;t need shitloads of useless boilerplate nor tons of XML, there are no pointless hoops to jump through, just plain solution which even slower runtimes can execute faster than JVM will execute your mammoth blobs.</p>
<p>ALSO:</p>
<p>All idiots crying &#8220;This is not how you would do this in Java, &#8230; yada yada&#8221;: it seems to me that this was the point of the post, which you somehow missed. But missing the point is perhaps to be expected from average [Java] code monkey.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcel Valdez</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1373962</link>
		<dc:creator>Marcel Valdez</dc:creator>
		<pubDate>Sat, 26 Jan 2013 18:58:41 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1373962</guid>
		<description><![CDATA[Functional programming in Java is as dangerous as Parallel and Concurrent programming is in Java.

Both will tend to be hard to understand and have hidden bugs. But that doesn&#039;t mean that it is *always* a bad idea. And both will require careful implementation from the programmer.

Just as it is a bad idea to unnecessarily use Parallel &amp; Concurrent programming in Java; it is also a bad idea to unnecessarily use functional programming in Java.

I think this is the point of this post. But you wrote the title as if it was a single universal truth. This reminds me of the &#039;[XXX] considered harmful&#039; articles.]]></description>
		<content:encoded><![CDATA[<p>Functional programming in Java is as dangerous as Parallel and Concurrent programming is in Java.</p>
<p>Both will tend to be hard to understand and have hidden bugs. But that doesn&#8217;t mean that it is *always* a bad idea. And both will require careful implementation from the programmer.</p>
<p>Just as it is a bad idea to unnecessarily use Parallel &amp; Concurrent programming in Java; it is also a bad idea to unnecessarily use functional programming in Java.</p>
<p>I think this is the point of this post. But you wrote the title as if it was a single universal truth. This reminds me of the &#8216;[XXX] considered harmful&#8217; articles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jujuju</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1369704</link>
		<dc:creator>jujuju</dc:creator>
		<pubDate>Fri, 25 Jan 2013 09:36:58 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1369704</guid>
		<description><![CDATA[Shity article
do you know Iterator ?]]></description>
		<content:encoded><![CDATA[<p>Shity article<br />
do you know Iterator ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rainer Joswig</title>
		<link>http://cafe.elharo.com/programming/java-programming/why-functional-programming-in-java-is-dangerous/comment-page-2/#comment-1366525</link>
		<dc:creator>Rainer Joswig</dc:creator>
		<pubDate>Thu, 24 Jan 2013 11:09:43 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=1031#comment-1366525</guid>
		<description><![CDATA[&gt; The answer is that Clojure, like pretty much all true functional languages (and unlike Java) does lazy evaluation.

Clojure does not do &#039;lazy evaluation&#039;. Clojure uses strict evaluation, like Lisp, Scheme, SML, OCAML, Erlang, ...

Clojure supports lazy lists. As a data structure - not in evaluation.

See also http://en.wikipedia.org/wiki/No_true_Scotsman]]></description>
		<content:encoded><![CDATA[<p>&gt; The answer is that Clojure, like pretty much all true functional languages (and unlike Java) does lazy evaluation.</p>
<p>Clojure does not do &#8216;lazy evaluation&#8217;. Clojure uses strict evaluation, like Lisp, Scheme, SML, OCAML, Erlang, &#8230;</p>
<p>Clojure supports lazy lists. As a data structure &#8211; not in evaluation.</p>
<p>See also <a href="http://en.wikipedia.org/wiki/No_true_Scotsman" rel="nofollow">http://en.wikipedia.org/wiki/No_true_Scotsman</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
