On Mon, Nov 17, 2008 at 9:49 PM, Maurí­cio <span dir="ltr">&lt;<a href="mailto:briqueabraque@yahoo.com">briqueabraque@yahoo.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; &nbsp;(...) &nbsp;I don&#39;t recall where I found the following example, but copied<div class="Ih2E3d"><br>
&gt; it locally as compelling evidence &nbsp;that the functional solution can be<br>
&gt; much clearer and &nbsp;shorter than the same solution &nbsp;modeled with objects<br>
&gt; and inheritance.<br>
<br></div>
Greg,<br>
<br>
I desagree with you. &nbsp;Bjarne Stroustrup, the original creator of C++, is<br>
a sensible person and I share his peacefull opinion in this matter:<br>
<br>
<a href="http://www.research.att.com/%7Ebs/bs_faq.html#compare" target="_blank">http://www.research.att.com/~bs/bs_faq.html#compare</a><br>
<br>
Even with good &nbsp;intentions, I&#39;ve never seen such &nbsp;kind of comparison not<br>
to fall into religious fights. (Although I&#39;m not more than just a humble<br>
language user.)<div class="Ih2E3d"></div></blockquote><div><br>Functional languages are much more formalized than OO languages. The basics (i.e. lambda-calculus algebraic data-types, *morphisms) are well known and very composable. OO theory is a mess, classes and objects are different beasts on every OO language and they don&#39;t form an easily composable toolkit (e.g. the inheritance vs. composition debate, where to place methods, binary method choices). There are many (which by sheer amount of variance isn&#39;t a good sign) formalizations of OO but none that were well received by the most popular OOPLs (in contrast with FP theory and it&#39;s pervasiveness in FPLs).<br>
<br>In this case it isn&#39;t a religious fight.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
&gt; -- Arithmetic expression forms data Expr = Num Int | Add Expr Expr<br>
&gt;<br>
&gt; -- Evaluate expressions<br>
&gt; eval :: Expr -&gt; Int<br></div>
&gt; (...)<div class="Ih2E3d"><br>
<br>
&gt; public abstract class Expr {<br>
&gt; &nbsp; &nbsp;public abstract int eval ();<br>
&gt; &nbsp; &nbsp;public abstract void modn(int v);<br>
<br></div>
Although I&#39;m not good enough to judge anyone&#39;s Haskell code, the Haskell<br>
version &nbsp;seems nice. &nbsp;I &nbsp;don&#39;t &nbsp;know how &nbsp;someone &nbsp;who understands &nbsp;well<br>
object-oriented code &nbsp;would do &nbsp;that. But I &nbsp;did C++ until &nbsp;around 1998,<br>
when the first standard was set, and &nbsp;I can tell you for sure that, even<br>
at that &nbsp;time, no one who &nbsp;knows at least &nbsp;the basics of C++ &nbsp;would ever<br>
write that problem like this.<br>
</blockquote><div>&nbsp;<br>Well, any OO programmer familiar with algebraic and coalgebraic datatypes would do that, it&#39;s the best way to model this problem (unless you mix it with extensible types but then we would fall in the expression problem territory and this isn&#39;t an easy problem to solve in any mainstream languages).<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Best,<br>
Maurício</blockquote></div><br>Best regards,<br>Daniel Yokomizo<br>