From: Rimantas Liubertas Date: 2009-12-12T22:56:55+09:00 Subject: Re: Wordpress Port >> > By contrast, Perl implemented OO rather well, >> >> Now that's funny. > > How so? It's is funny because you got it backwards. PHP5 has OO redesigned from scratch and Perl has, how to put it mildly, weird understanding how OOP is done. It was hacked on and it shows. It was you who provided this link: http://www.tnx.nl/php5.html. Did you try to read it carefully? All it does just tries to justify shortcomings/weirdness of Perl OOP by looking for workarounds or calling them "flexibility". Perl does not have private/protected? No big deal, you are a masochist if you want to use those. No abstract classes, no interfaces? No problem. But Perl supports multiple inheritance, woohoo! Have you actually seen _how_ Perl implements inheritance at all? You have to assign parent's name to special variable @ISA. That's the way to go. Constants? Perl programmers laugh at them. "Final"? Larry said that's a bad idea. But you will have in Perl6, anyway. Static variables? Who needs them. Exceptions? You have die() and eval() for that. Isn't it elegant: eval { … die … }; if ($@) { # handle exception } Eat that, try&catch! He complains about instanceof but does not mind the elegance of constructor in Perl: sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } And notice that "shift"? That's how you pass arguments to your methods. Or use @_. Flexible and elegant. He goes on to make fun of PHP4. Yep, OO in PHP4 was a joke, but guess what—Perl4 had no OO, it was all hacked into version 5. PHP5 may have not the best OO in the world, but to call Perl's OO implementation done "rather well" looks like a huuuuuge stretch to me. I understand very well that some my like or even prefer it this way, but I won't agree that that makes it any better. <…> > The question is, what does the language encourage? Is it easy to write good > code, and hard to write bad code, or vice versa? Is there syntactic sugar for > good habits, and syntactic vinegar for bad ones? Perl does not encourage writing good code any more than PHP does. And yes OOP in PHP5 looks much better than in Perl5. <…> Regards, Rimantas -- http://rimantas.com/