Karl Seguin

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
PHP vs ASP.NET
Do a Google search for "PHP vs ASP.NET" (or "ASP.NET vs PHP") and the first hit you'll get is a seemingly well-written Oracle article. When the article was first published, the .NET community certainly made note of it.  There's actually a follow up article by the same author, but he only skirts around the mistakes he made and never really corrects them.

This is exactly the kind of crap I was talking about earlier. Macromedia might write documentation with horrible code examples, but Oracle flat out lies. Shouldn't we expect more from Oracle? There's a fine print at the bottom of the article that says "The opinions expressed by this author are entirely his own and do not reflect the position of Oracle or any other corporation." That's of little value when it shows up on oracle.com and as the first hit on Google.

Honestly, who would ever buy a product/service from Oracle or iHeavy Inc. (the author's employer) when they clearly don't know what they are talking about? Sean Hull's article shows that opinions can be wrong, and ignorance is still king. I'm calling Sean out and daring him to prove me wrong!

Object Oriented:
So according to Sean, PHP 5 and ASP.NET both have "strong" object oriented capabilities. It's true that PHP5 language supports every important OO concept, but that's just one part of the equation. Anyone remotely familiar with the ASP.NET or WinForms control model knows that for .NET, being object oriented goes beyond the language.  In ASP.NET, html markup is represented as server-side objects. This provides the ability to easily program against controls as well as extend them.  Gone are the day of procedural includes, you now include an object you can program against. This is a non trivial difference that's at the core of the two platforms.  PHP5 has really good OO support, but compared to ASP.NET it isn't remotely close .


Exceptions:
Both PHP5 and ASP.NET support exceptions. Funny how your PHP code uses db_check_errors() for it's "exception handling". Is that how you handle exceptions in PHP? Funnier still is that your ASP.NET example doesn't have any exception handling (or the fact that this ASP.NET example uses Console.WriteLine). If you ignore the fact that PHP5 doesn't have a finally (or using), which is pretty minor, the fact is a number of built-in functions don't throw exceptions nearly as much as they should. Let's take a look at the PHP documentation for opening a connection to oracle:

$conn = oci_connect('hr', 'hr', 'orcl');
if (!$conn) {
   $e = oci_error();
   print htmlentities($e['message']);
   exit;
}


So PHP5 has good support for exceptions, but you'll mostly be checking return values to see if an exceptional situation occurred. Joel Spolsky might switch to PHP.


Speed and Efficiency:
PHP5 is quicker than ASP.NET because Sean said so. No benchmark code is provided. It just is! It's really hard to argue against such a phantom point.  I will say that PHP5 doesn't have a caching API out of the box or support for OutputCaching (you need a Pear library for that sort of stuff).  Oh ya, PHP5 is also more efficient, but there's no explanation as to what that means.


Price:
Any price comparison that doesn't take into account total cost of ownership is incomplete. Sean himself admits that "PHP is the quick and dirty type of solution". I know the TOC argument is thrown around by Microsofties a lot. But any experienced developer knows that maintenance cost can far outweigh all other costs. If PHP really is a quick and dirty (and it really is), shouldn't a sane business owner be worried about how easily and quickly they'll be able to maintain it?

I know this is an old article and most have let it go, but I feel duty bound to clear up some of the FUD. I work with PHP daily, and I do like it.  I plan on making a post about why you would pick PHP over ASP.NET (ie, if you are using the SqlDataSource, just switch to PHP now). But Sean clearly has no idea what he's talking about.


Posted Fri, Apr 28 2006 10:12 AM by karl

[Advertisement]

Comments

Sahil Malik wrote re: PHP vs ASP.NET
on Fri, Apr 28 2006 10:18 AM
I 100% agree with you.

I like to call them the anti-microsoft-left-wing-linux-hippie-leather-panty crowd. And frankly, most of their talk is not based on firm footing.
Jim Losi wrote re: PHP vs ASP.NET
on Fri, Apr 28 2006 12:53 PM
"anti-microsoft-left-wing-linux-hippie-leather-panty crowd"

yeah.. see if you can say that (PHP)5 times fast :)
Fregas wrote re: PHP vs ASP.NET
on Fri, Apr 28 2006 4:35 PM
Amen Brother.  I specifically avoided PHP because of the issues you mention.  Saying PHP 5 is object oriented is almost like saying ASP 3 is object oriented.
Sam wrote re: PHP vs ASP.NET
on Sat, Apr 29 2006 5:30 PM
It's good to hear an informed opinion, thanks.

I'd disagree with the characterization of ASP.NET as "OO" however. At least in the most common use case I believe ASP.NET is much more an Event driven framework than an OO one. I think it severly hampers Seperation of Concerns, Encapsulation (you have to know way too much about the Page Lifecycle for example), and makes really excessive use of set_methods outside of DAOs all point to it not being very OO at all, despite being written in a very OO language.

Not that skilled developers can't abstract away some of this, and produce flexible applications, but it's a difficult skill to master that the vast majority of ASP.NET developers will probably never approach I'd wager.
Ellis Web » Items of Interest: 2006.04.30 wrote Ellis Web » Items of Interest: 2006.04.30
on Sun, Apr 30 2006 5:11 AM
karl wrote re: PHP vs ASP.NET
on Mon, May 1 2006 9:58 AM
Sam,
I agree that ASP.NET is an event driven framework, which is probably a plus over php because web programming itself is event driven (or maybe I just think like that because I've been doing asp.net for 5 years).

The point about OO is still valid.  The .NET framework is richly OO. The .NET languages have first class OO capabilities. And ASP.NET has strong OO capabilities itself. But I totally agree that more important than language and framework is the person coding. And I more than strongly agree that most ASP.NET develoerps don't have the necessary  skills to master the OO nuances of ASP.NET. I think this is true of PHP as well.
Kalvin wrote re: PHP vs ASP.NET
on Tue, May 9 2006 6:37 PM
Sam, event driven and OO are not mutually exclusive characteristics. To me it is like saying: "A carrot is much more a vegetable than a solid". It makes no sense. One could program a sequential, OR an event driven system using an oo language.

The languages of ASP.NET are OO. There is no arguing that. They conform to the required properties of OO.
Ayodeji wrote re: PHP vs ASP.NET
on Tue, Dec 2 2008 9:15 AM

@Sam:

How do you mean ASP.NET is more "Event-driven" than OO? Have you been able to do anything is ASP.NET without crating a class?

ASP.NET is just a technology for the web. It has to be developed in any of the .NET languages, which are fully OOPs.

Syed Tayyab Ali wrote re: PHP vs ASP.NET
on Tue, Dec 2 2008 10:17 AM

ASP.Net rocks.

Eddie wrote re: PHP vs ASP.NET
on Fri, Jun 5 2009 8:15 AM

ASP.Net is running on IIS which is crap.

PHP is running on LINUX/UNIX/Apache , which is fast and reliable platform.

Unlike ASP.net, PHP doesn't hide the real thing from you.

ASP.NET is for WIN32 VB programmers who have no idea what Web is.

Give my best regards to Steave Balmer the monkey boy