Attention all ASP.NET developers, stop working in .NET and start using PHP! I'm convinced the successor to sliced bread is here! Let's all join and sing the praises of PHP. Don't have specifics? That's ok. No specifics needed in evangelical propaganda!
Come on. That's not what I'm saying at all. First I started posted here for the "phpfanboy BS" remark - to have some fun. Secondly I think I'm being pretty specific, without posting code. Most of what I've said is defence of PHP, i.e. the opposition to "Attention all PHP developers, stop working in PHP and start using ASP.NET!".
>I think you need to replace "True OO languages" with "Fully OO
>languages".
I'm tiring of the semantical game here. Call it what you want. PHP as a language doesn't compare with "Fully OO languages". I rest my case.
My point was PHP is able to be a true OO language. Java and .NET are fully OO languages. In PHP you have a choice. PHP is trying to walk a road which lies between procedural and OO coding. It remains to be seen whether this will result in something good or bad (I'd say wait to see what happens in the year following Zend 2). Like the SAX vs DOM argument, PHP is in search of a third way and perhaps it will deliver.
Events
Again it's another you can do yourself in PHP. Microsoft has taken that burden away from developers. That's not to say PHP can't do it.
I'd like to thank
pickyh3d for a reasoned response - agree with most of what you're saying.
PHP does not support polymorphism 100%.
It does. There's a general (although a little old - some of the things discussed have been improved) article here:
http://www.phpbuilder.com/columns/luis20000420.php3?print_mode=1. Here's a simple example;
<?php
/* A possible user interface library */
// Base class
class UserInterface {
// Displays a form - force it to be implemented in children
function displayForm() {
trigger_error('Method not implemented');
exit();
}
}
// Child class
class XHTML extends UserInterface {
// Method of same name overwrites parent method
function displayForm() {
echo ( 'A XHTML form' );
}
}
// Child class
class WML extends UserInterface {
// Method of same name overwrites parent method
function displayForm() {
echo ( 'A WML form' );
}
}
// Child class
class Flash extends UserInterface {
// Method of same name overwrites parent method
function displayForm() {
echo ( 'A Flash form' );
}
}
?>
A simple way to use this library might be;
<?php
// Include the library
include_once('UserInterface.class.php');
// Build an array which effectively acts like a SWITCH statment.
$mimeTypes= array ('XHTML'=>new XHTML, 'WML'=>new WML, 'Flash'=>new Flash);
// Instantiate object depending on a GET variable "mime"
$userInterface=$mimeTypes[$_GET['mime']];
// Call the polymorphic method
$userInterface->displayForm();
?>
PHP doesn't really support
multiple inheritance - this is not possible ;
Child extends Parent1, Parent 2 {
}
This can only be done with workarounds right now but is coming to Zend 2. But hey - Java (a fully OO language as we all agree) doesn't support multiple inheritance either (need workarounds). And some would argue multiple inheritance is a bad thing (such as Java's designers).
1st Party vs. 3rd Party
That's a very good point you make. One open source language which has got this right, IMO, in Perl - CPAN is trully impressive and is a 3rd party collection which amounts to a 1st party "product".
PHP's equivalent to CPAN is PEAR, and the response to PEAR amongst many PHP developers is mixed. PEAR certainly doesn't match up with a library like Java's but given that may change (e.g. Zend 2 allows for a libary to be implemented via a namespace...). Lack of unified library may be PHP's biggest weakness. But it may be it's biggest strength as well, for the time being, while
The main reason I'd personally avoid .NET, for the forseeable future, is I know MS will use it purely as a means to get me to buy their (expensive) products and lock me in. I write my ASP.NET application and if I want to go productive with it, I have to buy a Windows Server with some incarnation of IIS.
And sorry but no matter how big the company, relying on them to deliver everything always results in heartache. IBM have learnt their lesson already and discovered you're better off selling consultancy and experience, not products.
I won't harp on about past records but taking one example - I trust the Apache Group to get their web server right - a small organisation focused on a specific goal. Not so Microsoft with IIS, who have a million and one other interests which may take precedence over my needs (let's face it - MS only took security seriously after 9/11!). And that magic word "Free" is very inticing...